• Create Account

## Mario terrain (Pseudo)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Nick Murphy  Members

1604
Like
Likes
Like

Posted 15 July 1999 - 03:29 AM

I was playing Super Mario Bro. 4 on my SNES
emulatorand I started to wonder how they did the
terrain collision detection? I have played around with
tile based side scrolling games, and I have always split
the map into a grid, and had a variable for wether
each one is passible or not. This sucks, and I have
wanted to do something a bit more sophisticated.
Mario seems to have a good system going, the terrain
can be at a slant. (my system couldn't) If anyone can
clue me in on how this type of system works, I would
much appriciate it.

### #2Nick Murphy  Members

1604
Like
Likes
Like

Posted 14 July 1999 - 08:04 PM

What you could maybe do is have some variables that
let you know whether the terrain is sloped. Like
b_slopeleft = true; would mean that the terrain has a
slope to the left. or maybe even

#define LEFT_SLOPE 0
#define HORIZONTAL_SLOPE 1
#define RIGHT_SLOPE 2
#define VERTICAL_SLOPE 3

if (m_slope == LEFT_SLOPE)
// the ground is sloping to the left
else if (m_slope == RIGHT_SLOPE)
// the ground is sloping to the right
else if (m_slope == HORIZONTAL_SLOPE)
// the ground is flat
else if (m_slope == VERTICAL_SLOPE)
// have some sort of barrier here, or just vertical
terrain

I hope you get the idea.

Khawk

### #3 Anonymous Poster_Anonymous Poster_*   Guests

Likes

Posted 14 July 1999 - 11:59 PM

When it comes to actually figuring out HOW to place Mario on a sloping tile you alter his Up-and-down(y position) according to how far Mario is into the tile in the X position using a table or array
tile offset y offset
0 0
1 1
2 2..
15 15
Now you just look up in the table using the x offset in the tile as an index to the y offset.

For even more irregularly shaped ground(like curves), associate another tile with an array of ones and zeros and test the x,y offsets of the bottoms of your sprites. If it's a one, subtract a few from your sprite y position to position your sprite higher and test again before actually placing the sprite
You might want to test the bottom left, bottom centre, and bottom right if you're in the actual curved tile itself. We don't want Mario impaled in the ground. Though if it's a fast-moving game maybe no one will notice.

### #4Akura  Members

130
Like
Likes
Like

Posted 15 July 1999 - 03:29 AM

Hi, this is really a physiscs problem but can be arranged much simplier. First use the idea of the 0 for left and so on but with one difference, ou will need a signed var (char should do it) and make 0 for horizontal tiles, then 1 and more to right slope tiles, the greater the number the greater of the inclination of the slope, and the same for negative, but this time the smaller (-34 is smaller than -4 remmeber) th ebigger is the slope for the left I think that should solve the problem, and you can get different inclinations for your tiles

Bye

------------------
Bruno Sousa aka Akura
Founder and programmer - Magick.pt
[mail]magick_pt@geocities.com[/mail]
http://magickpt.cjb.net

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.