Thread: Side-scroller Level Design

  1. #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

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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.
    Last edited by dwks; 04-23-2007 at 10:25 PM.
    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.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  4. #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

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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.

  6. #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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Diablo's random level generation
    By glo in forum Game Programming
    Replies: 7
    Last Post: 07-19-2008, 03:04 AM
  2. Strange side effects?
    By _Elixia_ in forum C Programming
    Replies: 4
    Last Post: 08-16-2005, 03:25 PM
  3. printSquare( side ); ???
    By o0o in forum C++ Programming
    Replies: 2
    Last Post: 01-09-2004, 05:50 AM
  4. Need Help with 2D Garden Design Program
    By frgmstr in forum C++ Programming
    Replies: 7
    Last Post: 02-04-2002, 04:58 PM
  5. game design from the non programming side
    By Scourfish in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-29-2002, 01:07 AM