#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    232
    Rep Power
    17

    Simple Game Question


    Hello, Im wondering with Live action RPGs, FPSs and such. How do you check if the user is dead while your waiting for a key input?


    (I know this isnt code its a design) I always thought games go like this:
    Code:
    Game Loop Starts:
     Wait for user input
     Check what user inputed
     Collision Detection
     AI Logic
    Game Loop starts again.
    But what if the player is attacked while waiting for the user to input something? How would u move AI while waiting for the user to input something?

    - Cheers, Daniel
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Your loop is slightly incorrect. Instead of "Wait for player input", it should read "Check if player input" and continue through the loop if there is no input.

    Comments on this post

    • tagmanadvance agrees : yup. Threading should be used for this.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    232
    Rep Power
    17
    So I should use multithreading for this?

    And what happens if a user inputs a key while its doing the AI logic and such.

    - Cheers, Daniel
  6. #4
  7. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Location
    Switzerland
    Posts
    1,152
    Rep Power
    1902
    Originally Posted by drezard
    So I should use multithreading for this?

    And what happens if a user inputs a key while its doing the AI logic and such.

    - Cheers, Daniel
    Yes.

    You should have a few threads each specializing on something. One for getting user input, one for AI logic (probably one for every ai), one for for sync'ing with the server, one for display...
    I'm no expert on game programming but it should go along those lines.

    Then you can have the system take care of doing all of it "together". What you still will have to do is that the different threads don't mess with each other. You do this by ensuring that a thread that reads or writes some data doesn't get interrupted by another thread writing or reading that data...
    Monitors, Semaphores and Deadlock Prevention are some keywords to look up for this.

    Won't be easy though...

    Comments on this post

    • jorgejones disagrees : And you should make another thread to scratch your balls too! - Because you're over-killing the entire idea here. Thats just overkill, read a book god damnit. Even on Intel's manuals you'll read onto proper multithreading.
    - Hugh of Borg

    The first thing young borg are taught: Keep away from Microsoft software!
  8. #5
  9. Kage Bunshin
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2005
    Location
    The Seven Seas Of Rhye
    Posts
    930
    Rep Power
    423
    Thats why you find a good 3rd party game development engine. Its faster, often easier, and hopefully some good support.
    "Java makes impossible things possible, but makes easy things difficult." - Somebody

IMN logo majestic logo threadwatch logo seochat tools logo