Hi Kai,

Well, to help me draw level maps I actually created a level editor
that allows me to copy, cut, and paste things like walls, doors,
chasms, etc on a 2d or 3d grid. However, even without it it is not
that hard to actually draw or create a level such as you describe. To
create a room for a side-scroller all I need to do is something like

// Draw the ceiling
for (x = 0; x < 51; x++)
    g_map[x, 10] = SURFACE_CEILING;

// Draw the floor
for (x = 0; x < 25; x++)
    g_map[x, 0] = SURFACE_STONE;
for (x = 36; x < 51; x++)
    g_map[x, 0] = SURFACE_STONE;

// Draw the chasm
for (x = 25; x < 36; x++)
    g_map[x, 0] = SURFACE_CHASM;

// Draw the left wall
for (y = 1; y < 10; y++)
    g_map[0, y] = SURFACE_WALL;

// Draw the right wall
for (y = 1; y < 10; y++)
    g_map[50, y] = SURFACE_WALL;

What we have here is a simple room 50 units wide and 10 units high. We
essentually created it by using surface constants and stored them in a
2d array. To figure out if we encountered anything all we need to do
is find out if the player's next x/y position will step into a chasm
or encounter one of the walls. Since my engine, G3D, actually deals
with a 3d array with an x/y/z position I have a set of trig formulas
to calculate the vector and figure out where the player's next x/y/z
position will be. However, since we are dealing with a simple
side-scroller we probably don't need anything that fancy. We can get
by just by adding or subtracting the player's velocity to or from x
and y. For example, here is some really really simplistic colision
checking. This isn't exactly the best collision detection method, but
it should work for a newbie like your self.

// Get the player's x/y coordinates
float speed = g_player.GetSpeed();
float x1 = g_player.GetX();
float y1 = g_player.GetY();
float x2 = 0;
float y2 = 0;

// If the player is moving left
// subtract the player's sspeed from x1
if (g_player.GetDirection() == -90)
        x2 = x1 - speed;
        y2 = y1 - 1;

// If the player is moving right
// add the player's speed to x1
if (g_player.GetDirection() == 90)
        x2 = x1 + speed;
        y2 = y1 - 1;

// Get the player's surface
int surface = g_map[(int)x2, (int)y2];

// Find out if the player encountered anything
int encountered = g_map[(int)x2, (int)y1];

// If the player stepped into a chasm kill the player
if (surface == SURFACE_CHASM)

// If the player hit a wall
// stop moving
if (encountered == SURFACE_WALL)

// Move forward
if (encountered != SURFACE_NOTHING && surface!= SURFACE_CHASM)
        g_player.SetLocation(x2, y1);

What we have here is a very simplistic colision detection system. It
basically tries to determine where the player will be when he/she
takes their next step and figures out if he/she hit a wall, fell into
a chasm, or moved safely to the new location. Does this make sense?

So if I wanted to add ledges etc to this room above all I'd have to do
Is draw them in by adding them to the array wherever I wanted them. I
might draw one in the middle of the chasm to jump/land on so the
player doesn't have to try the suicidal feet of jumping the entire
length of this chasm, or I could add ledges to either side. It really
is not that complex to create a level in this fassion.


On 12/28/10, Kai <kaixi...@sbcglobal.net> wrote:
> Greetings Thom and Jim.
> Thank you for your responses to this subject.
> Thom: I do remember the in-depth discussion you,Kara, and crew were having
> about levels, vectors, and all that mind-boggling stuff. Most of it went
> right over my head however, as I'm horrible with math in all its forms.
> I guess my difficulty is in grasping spatial considerations. for example, in
> the game I'm envisioning, the player travels down a north/south corridor
> nine sectors wide. Assuming he stays in the center at sector 5 and walks
> down the corridor, once he encounters an obstacle (chasm, boulder, wall,
> etc), the obstacle may be at its widest point at that sector (in the example
> involving a chasm, therefore, that'd be where the chasm is widest across).
> In games where all obstacles are the same dimension (like Super Liam),
> there's no problem. But what if I want to make the obstacle taper off or
> have smaller points? (Perhaps a ledge that extends out into the chasm,, for
> instance.) Even in a two-dimensional environment, the implications of such
> calculations slightly baffles me. I understand the principle (make the array
> different at one or more coordinates), it's the actual perception of it in
> my head that throws me for a loop.
> and let us not even talk about adding a Z axis to such a game, wherein jumps
> and scalable obstacles can change the player's vertical position.
> Obviously, such a game of this magnitude is by no means going to be my first
> venture, but I would still like to comprehend the idea before I even attempt
> to make a foray into this region.
> Kai

Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
All messages are archived and can be searched and read at
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to