Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a small platformer game with multiple levels, similar to old-school Mario, and I was wondering how devs created levels. This is my first game, so I'm pretty new to design & such. I've seen people use Paint.NET or Photoshop to create a level where certain colors in the world represent various tiles & such, that are rendered throughout the level. For instance, a red block in the world on a blue background would represent a tile that a player can jump on, and would be rendered so when the game is started. Is this an effective way of designing levels, or is there a better way? Please explain your process.

share|improve this question

closed as primarily opinion-based by Nicol Bolas, bummzack, Anko, Byte56 Jul 29 '13 at 22:54

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 0 down vote accepted

For such a task you create/use an level editor. In the editor you can do all sorts of things, place tiles, lace enemies, program/link/load scripts, set effects, ...

I actually don't know any standard 2d Level Editor.

Creating a Level Editor is no simple task but here are some hints how to get started:

  • keep it for the beginning simple, use your cursor keys for navigation in the world and some other keys to set the tiletype of the currently selected position
  • later you can create a "simple" GUI to choose stuff to insert / change

just keep it simple so you don't waste too much time if you decide to throw it away.

share|improve this answer
Thanks for the answer. Would you mind adding some more details, such as level editors that I could use or how I might go about creating one (in a brief way)? – hasherr Jul 27 '13 at 22:30
@hasherr you can use something like Tiled to make tile-based levels. You just need some *.lua or *.json library to read some of the easier export formats. There's more similar editors but I haven't tried those. – PeterT Jul 28 '13 at 0:07

I have created a level editor for a 2d top-down rpg. The principles are exactly the same for a 2d side-scroller like mario.

Here is what I did.

I created an 4 arrays of numbers. Each array represents a layer and each number in the array represents a tile. A tile is simply a square chunk of pixels. The location of the number in the array represents the location on the screen the tile should be drawn to. So with an array of size [10][10], setting [5][5] to the number 1 would draw, let's say grass, to the center of the screen.

When you create your map editor, you'll want to display all the available tiles the user can use to paint the level. When a user selects a tile in the map editor there should be some indication that the tile has been selected and the tile should have a number associated with it.

When the user clicks somewhere on the screen, you detect which area he clicked on and send the tile's number to the array responsible for the layer he's drawing on. that way you fill each array with tile numbers so that when you render the map, you only need to iterate through each array and draw the tile based on the tile number and position in the array.

You'll need to determine how large you want your levels to be. For a sidescroller you'll want a very wide 2d array, maybe something like ground[50][500] for the ground layer.

To implement layers, simply draw them in order. It may be something like ground, background, player sprite, foreground foreground2. The player sprite will then draw on top of the ground and background layers and the two foreground layers will cover the sprite.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.