FPS: 5

After playtesting Automata extensively, I found that the framerate slows considerably when more enemies are added. 1 enemy = 30 FPS running at 100% CPU, 50 enemies = 5 FPS running at 100% CPU. More tiles also slow the framerate down, from 9-10 FPS to 5-. FPS. I suspect that if the screen was almost filled with tiles and 50 or so enemies were on the screen, my game would run at 1 FPS.

(log in to comment)


What does a enemy exactly? I mean AI. How is implemented?
It follows the player. Here's some pseudocode:

  direction = random number
  if direction is 1 then go (right or up)...

  if colliding(tile) move back
Each enemy is checking collision against every tile in the scene. Multiply # enemies by # of tiles and you should quickly see why the game is slow. A much better collision scheme for a grid like this would be to store a map of 1's and 0's, check on the map which tile the enemy is moving to, and see if it's a 1 or a zero. That is a single fast call, rather than collidemany, which in actuality is width*height calls.

For a more complex environment you would want some kind of partitioning scheme, so the enemies would only run the collide function on nearby objects that it could conceivably collide with.

on map load:
#Build empty map
map = []
row = []
while 1:
   if len(row)==map_width:
      row = []
      if len(map)==map_height:

for tile in loaded_tiles:
    row[tile.y][tile.x] = 1

#for collisions
tile_x = enemy.x//tile_width
tile_y = enemy.y//tile_height

if left: tile_x-=1
if right: tile_x+=1
if up: tile_y-=1
if down: tile_y+=1
if tile_x<0 or tile_y<0 or tile_x==map_width or tile_y==map_height:
   collide = 1
elif map[tile_y][tile_x]:
   collide = 1
   collide = 0
Aha. I never thought of that. I'll implement it and update again. Thanks!
A 30 FPS speed boost is the result. :)
Not at this point in the comp, but you could also do what I did and make all objects sprites, then get the tile on the map at the edges of it's rect, and then see if they're solid or not.  I find that strategy good because it allows me to do crazy things like animated tiles, switches, and doors, all in the level code, never having to deal with creating those objects.
Yous all usse very complicated collision detection. Ever hear of K.I.S.S? Keep It Simple Stupid. it works. :P
Also, check python itertools. For the mutant tetris (lol) im using numpy for collision detection and works fine. God, lately im obsessed with numpy...

that's not bad. numpy is pretty awesome
by all means, go simple if possible, my complicated version a) is for a sidescroller with per-pixel movement and b) allows me to do things with the level files that I have yet to be seen done (switches and doors, changing player)