![]() |
| | #1 |
| C++ Enthusiast Join Date: Mar 2005 Location: MI
Posts: 532
| Side-scroller Level Design
__________________ Trinity: "Neo... nobody has ever done this before." Neo: "That's why it's going to work." c9915ec6c1f3b876ddf38514adbb94f0 |
| jmd15 is offline | |
| | #2 | |
| Frequently Quite Prolix Join Date: Apr 2005 Location: Canada
Posts: 7,698
| Quote:
I would store each level in a different file, simply because they're easier to manage that way. If one file gets corrupted, you don't lose everything. If you want to add a level, delete or edit one, it's a lot easier. How to store the data? I would use text. That's just me. Text files may be larger than binary files, but they're easier to read, easier to edit, and often more portable. Depending on how big your maps are, there are two basic ways to store the data. You'd probably just store the value of every square, much like this: Code: A A B B A A A A A Code: B 2, 0 B 0, 1 Another suggestion: to make the levels easily customizable, you could have a header like this: Code: A tile.png B wall1.png C wall2.png
__________________ dwk Seek and ye shall find. quaere et invenies. "Simplicity does not precede complexity, but follows it." -- Alan Perlis "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra "The only real mistake is the one from which we learn nothing." -- John Powell Other boards: DaniWeb, TPS Unofficial Wiki FAQ: cpwiki.sf.net My website: http://dwks.theprogrammingsite.com/ Projects: codeform, xuni, atlantis, nort, etc. Last edited by dwks; 04-23-2007 at 10:25 PM. | |
| dwks is offline | |
| | #3 |
| Super Moderator Join Date: Aug 2001
Posts: 7,804
| I use linear arrays to store levels. What you use is purely up to you. But arrays are easy to load/save and to manipulate in-game. |
| Bubba is offline | |
| | #4 |
| C++ Enthusiast Join Date: Mar 2005 Location: MI
Posts: 532
| Thanks for the replies. dwks, your argument convinced me to use separate files for each level. Now for the way/style of storing the levels in files. I was thinking of assigning codes like (A1, A2, A3, etc) for each object, the letter corresponding to the type of object and the number to the specific one, etc. So the files would look like this: A1 50,20 A2 100,20 A3, 25,35 With the numbers after it being x,y values. Then when reading the level files, I could store each set of coordinates in one 2d array, and then store the name of the object/sprite to draw in a corresponding array under the same index number. Then to make it run faster, I could check the current frame of view each game loop, and draw all sprites in those arrays with coordinates that lie within the frame. Is that a sound level design idea? Not being well versed in game design, any tips/suggestions on this are welcome. Bubba, what are these "linear arrays" you talk about? I'm not familiar with those. Thanks for the suggestions guys.
__________________ Trinity: "Neo... nobody has ever done this before." Neo: "That's why it's going to work." c9915ec6c1f3b876ddf38514adbb94f0 |
| jmd15 is offline | |
| | #5 |
| Frequently Quite Prolix Join Date: Apr 2005 Location: Canada
Posts: 7,698
| That's just what I was suggesting in my post. But I think that in your file you should assign A1 etc to filenames if you can, to facilitate changing artwork.A linear array is just an ordinary array AFAIK.
__________________ dwk Seek and ye shall find. quaere et invenies. "Simplicity does not precede complexity, but follows it." -- Alan Perlis "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra "The only real mistake is the one from which we learn nothing." -- John Powell Other boards: DaniWeb, TPS Unofficial Wiki FAQ: cpwiki.sf.net My website: http://dwks.theprogrammingsite.com/ Projects: codeform, xuni, atlantis, nort, etc. |
| dwks is offline | |
| | #6 |
| C++ Enthusiast Join Date: Mar 2005 Location: MI
Posts: 532
| Ok, thanks. ![]() I get your filename idea, but I'm planning on writing different classes(using inheritance off of a main Sprite class) for each specific sprite. So that way, the A1 naming system will specify a certain class which will have that class's sprite image file loaded on creation into it's inherited SDL_Surface member. I think I'm ready to begin development know! woo! Thanks again guys, appreciate it!
__________________ Trinity: "Neo... nobody has ever done this before." Neo: "That's why it's going to work." c9915ec6c1f3b876ddf38514adbb94f0 |
| jmd15 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Diablo's random level generation | glo | Game Programming | 7 | 07-19-2008 03:04 AM |
| Strange side effects? | _Elixia_ | C Programming | 4 | 08-16-2005 03:25 PM |
| printSquare( side ); ??? | o0o | C++ Programming | 2 | 01-09-2004 05:50 AM |
| Need Help with 2D Garden Design Program | frgmstr | C++ Programming | 7 | 02-04-2002 04:58 PM |
| game design from the non programming side | Scourfish | A Brief History of Cprogramming.com | 0 | 01-29-2002 01:07 AM |