C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-23-2007, 05:40 PM   #1
C++ Enthusiast
 
jmd15's Avatar
 
Join Date: Mar 2005
Location: MI
Posts: 532
Side-scroller Level Design

I'm wondering if anyone knows of a good article on the level design behind side-scrollers? I'm currently programming a 2D, SDL-based, side-scroller and I've got mostly everything else developed, I just need an idea for the levels. I haven't even decided on how to set up the levels. Should I store all the levels in a file? In separate files? How should the data look in the files? How should the data be parsed? Any help or links are appreciated. Thanks.
__________________
Trinity: "Neo... nobody has ever done this before."
Neo: "That's why it's going to work."
c9915ec6c1f3b876ddf38514adbb94f0
jmd15 is offline   Reply With Quote
Old 04-23-2007, 10:21 PM   #2
Frequently Quite Prolix
 
dwks's Avatar
 
Join Date: Apr 2005
Location: Canada
Posts: 7,698
Quote:
Originally Posted by jmd15 View Post
I'm wondering if anyone knows of a good article on the level design behind side-scrollers? I'm currently programming a 2D, SDL-based, side-scroller and I've got mostly everything else developed, I just need an idea for the levels. I haven't even decided on how to set up the levels. Should I store all the levels in a file? In separate files? How should the data look in the files? How should the data be parsed? Any help or links are appreciated. Thanks.
It's entirely up to you.

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
But if there are vast distances between object on the map, or very few objects, or the values must be very exact, you could store it more like this:
Code:
B 2, 0
B 0, 1
(That is, store the positions of each non-blank square instead of every square.)

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
Then in the file you use A, B, C etc for the squares. That way you could very easily create different themes or whatever you like.
__________________
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   Reply With Quote
Old 04-23-2007, 11:58 PM   #3
Super Moderator
 
Bubba's Avatar
 
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   Reply With Quote
Old 04-24-2007, 03:02 PM   #4
C++ Enthusiast
 
jmd15's Avatar
 
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   Reply With Quote
Old 04-25-2007, 02:08 PM   #5
Frequently Quite Prolix
 
dwks's Avatar
 
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   Reply With Quote
Old 04-25-2007, 02:48 PM   #6
C++ Enthusiast
 
jmd15's Avatar
 
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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22