Thursday, April 9, 2009

Map editor

Piece of advice. Follow the recommendation from the designer diary. Use some kind of "map editor" to create your levels.
My approach: I had functions to generate the different towers. Then functions to generate the levels and finally a "renderer" function that created and placed all the blocks onscreen. This way I was able to easily plug this renderer function in and out and exchange it for a command line one for quick debugging.

My world editor in action screenshot.

And the source code for the level creation is as clean as this:
function createlevel()
x =worldmin + 20 * level
if level == 1 then
for k,v in pairs(towere(x,height)) do create(v,false) end
elseif level == 2 then
for k,v in pairs(tower(x,height)) do create(v,false) end
for k,v in pairs(tower(x+2,height)) do create(v,false) end
create(block(x+1,(height+1)*2,BENEMY),false)
elseif level == 3 then
for k,v in pairs(tower(x,height)) do create(v,false) end
for k,v in pairs(tower(x+2,height)) do create(v,false) end
for k,v in pairs(tower(x+4,height)) do create(v,false) end
create(block(x+2,(height+1)*2,BENEMY),false)
elseif level == 4 then
for k,v in pairs(tower(x,height+1)) do create(v,false) end
for k,v in pairs(tower(x+2,height)) do create(v,false) end
for k,v in pairs(tower(x+4,height-1)) do create(v,false) end
create(block(x+2,(height+1)*2,BENEMY),false)

No comments:

Post a Comment

Bounce'em Down Game

Bounce Widget