Re: Help me with game logic

To calculate delta, record the time the last frame started, then record the time the current frame is going to start, and subtract.  If your time implementation  gives you milliseconds, you'll want to divide by 1000 and store it in a float.

The easiest way however is to decide that you're going to tick say 10 times a second, do delta = 1/10, and just always use that value.

What you do with it is you say that "the max velocity of my player is going to be 5 meters per second", you find out if they're currently supposed to be walking (usually via an isWalking variable, or just setting velocity to something that's not zero), then you do delta*velocity to find out how much they should have moved by this frame.

The advantage is that if you do delta right, and the game stutters because it got preempted or something, you can still make sure the player moves the right amount.  It also lets you decide that you're going to tick 60 times a second instead of 10 times a second, or what have you, without having to change all of your game logic around.

To do footsteps, you can either loop the sound as long as isWalking is true, or you can play a footstep every time the player moves a certain amount.  The former will sound better with the disadvantage that it's not going to change how fast the footstep is based on velocity.  The latter will sound like the player is drunk without a bit more work.

But it may be easier to ignore all of this and do what @2 suggests for your first game.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Nuno via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Nuno via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to