Game Dev Diary: Asset Reuse Invaders v0.11

Game Dev Diary: Asset Reuse Invaders v0.11

Exciting things have happened! I figured out how to make tables inside tables inside tables, and having made use of it like this:

 levels[4] = { {3,3,3,3,3,3,3},
               {2,2,2,2,2,2,2},
               {2,2,2,2,2,2,2},
               {1,1,1,1,1,1,1},
               {1,1,1,1,1,1,1} }

I was able to create 20 different levels, with different layouts. I had to modify my invader creation routine:

function create_invaders()
 newlevel = level
 if newlevel > 20 then newlevel = 20 end
 newinvspr = 0
 for row = 1,#levels[level] do
  for col = 1,#levels[level][row] do
   --           (invspr,invx,invy,invdx,invdy,invticks,invticksmax)
   newinv = levels[level][row][col]
   if newinv == 0 then newinvspr = 0 end
   if newinv == 1 then newinvspr = invaderasprite end
   if newinv == 2 then newinvspr = invaderbsprite end
   if newinv == 3 then newinvspr = invadercsprite end
   if newinv != 0 then
    make_invaders(newinvspr,newinv,8*col,8*row+16,1,2,1,5)
   end
  end
 end
end

See that #levels[level][row][col] notation? That’s the clever bit I was trying to get my head round. Very pleased with this.

In addition, I’ve modified the player sprite, changed the title and Game Over screen, and implemented three different cats that fire at different rates and speeds.

The upshot of all this, is I have what could be considered a finished game. There’s still no sound, of course, and there’s some tidying up to do with things. And I haven’t done the UFO either. But, it’s nearly there and – bugs notwithstanding – fully playable!

[includeme src=”https://lofi-gaming.org.uk/gamedev/ari011/invaders.html” frameborder=”0″ width=”400″ height=”400″]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.