Archived

This topic is now archived and is closed to further replies.

BigBadDom

Writing and loading large levels

Recommended Posts

BigBadDom    122
I am just getting into game programming and have read a couple of books on the subject, however, they all seem to deal with small games. They have no information about how to create or load large levels without having to instantiate and place every single sprite, wall or tree individually into the code. I want to be able to write a medium sized game with the flexibility to easily change and create levels. If anyone knows of a good book on this subject or has any top tips I would be most appreciative. (Specifically interested in writing a 2D game with DirectX using C++)

Share this post


Link to post
Share on other sites
ManoliIsFat    122
if its a 2d scroller, the easiet thing to do is have a huge array of tiles. each tile would represent a different object (0 could be space you can move through, 1 could be a brick)

so if you have a 3x3 level, it'd look like this.

int level[3][3];

level[0][0]=0;
level[0][1]=1;
level[0][2]=1;
level[1][0]=0;
level[1][1]=0;
level[1][2]=1;
level[2][0]=0;
level[2][1]=0;
level[2][2]=0;

then you'd have a function to load the level into the game.

the only problem here is that it takes FOREVER to code a fairly larged sized level like this, so the best thing to do is to create a level editor that will save this array to a file, and then have your program load this file into your level array.

hope that helped.






[edited by - manoliisfat on October 22, 2002 1:22:16 PM]

Share this post


Link to post
Share on other sites