Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nick Murphy

Mario terrain (Pseudo)

This topic is 7012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!