Advertisement

Hills for 2D platform games

Started by October 10, 2000 11:06 AM
0 comments, last by trocadero 24 years, 3 months ago
Hi I am working on a 2D platform game for fun. But does anyone have any idea how to do those hills they have in games like Super Mario bros 3 ? Where the ground go up like this: / Edited by - trocadero on 10/10/00 12:18:32 PM
OK, There are a lot of ways to do this, but I think the best way for a beginner (and probably the best way all around...) is to use an array of "tile structures" to represent your map.

typedef struct S_TILE {
unsigned short tile;
unsigned char state;
} TILE;

Now you build an array of these tile structures...

TILE map[128][32];

Each tile represents a (as an example) 32x32 pixel are on the map. Obviously the "tile" member holds the id of the actual graphic to be drawn in your map. The "state" member can hold info about whether or not the tile is solid. For instance, a completely solid tile might have a state of 1, completely empty being 0. then a 45 degree slope up and to the right might be 2, down and to the right 3, ...etc.

As an alternative, you might change "state" to an unsigned long and use it as a bitmask defining which pixels are solid and which aren't.

On second thought, instead of changing state to a long, just include the bitmask as part of the tile graphic, and store it with the tile graphic structure...

Edited by - novalis on October 10, 2000 12:26:43 PM
If a man is talking in the forest, and there is no woman there to hear him, is he still wrong?

This topic is closed to new replies.

Advertisement