Most efficient way to do some things


(Granit Bajraktari) #1

I’m developing a game with FlashPunk and I am doing well so far (although i can’t really even draw a circle on the screen using AS3).

I wanted to know if these are the most efficient ways to do certain things:

  • Should I handle user Input in the Game World (there is only one world) or in the player class itself or even in the main class. I handle it in the Game World.
  • How should I make a piece of code only execute if some time elapsed, currently I make a uint counter variable and increment it every frame and then I check if the counter is let’s say 180 or larger (3 seconds since the game is 60 fps), if so, the code gets executed and I assign the counter to 0. Also I can’t use FP.elapsed since I’m using a fixed timestep.
  • Should I play music as a regular sound effect or is there some “special” class for doing that.

(Zachary Lewis) #2

That’s where I like to handle it.

Counters are fine. You can also look at the Alarm class, but if you have a way that works, I’d just stick with it.

Yep. Instead of using play(), use loop().


(Granit Bajraktari) #3

Thanks for the help!