• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

103 Neutral

About WJM

  • Rank
  1. [quote name='Slavik81' timestamp='1333492385' post='4928023'] There's almost no way that the ifs/switches determining what to draw would be significant. That sort of code is trivial in execution cost and relatively rarely executed. Your problem is far more likely to be due to whatever you're doing once you determine what to draw/animate. [/quote] thanks, I think I'll try to make it draw 2 large bitmaps instead of each tile.
  2. Hey guys, all Oz references aside, I got a question. Basically, I have a game (using Allegro), and its coming along very nicely, I have a map, tiles, enemies, textures and the lot, but I notice that the lag tends to spike at what (seems like) random. I'll get to why I think its lagging later, but I should probably go over the whole things for the sake of completeness. Every cycle (tick, whatever you want to call it), the game draws all the tiles (including water and lava, which are animated with 2 frames), runs the enemy through its AI once, then draws the player and the enemy (both use the same animation technique). All the tiles store a pointer to their image (and a second one in case they're animated), and are in turn stored in a room object. Now,I think the player object is particularly ugly and lag prone because of its animation function. it uses an if statement to check if there is an animation started, then another if statement for each direction the player could be facing (NESW), then a switch for what frame to draw. The switch uses an integer that gets advanced with each tick, and reset to 0 when a new animation is started. There's also some other switches for standing still etc. Is it the amount of if/switch statements slowing it down? or is it something else I'm not aware of. I hope that makes sense.
  • Advertisement