Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2d Terrain???

Author
Message
Yitzu
13
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 19th Apr 2010 19:07
This thing about terrains is new to me, so im not pretty sure about how to make it.

I've seen some 3d terrains examples, but, the problem is that my game is in 2d, so i have no idea of how to make it work...

I want my main character or hero to follow the terrain and change its height with it... someone can give me an idea of how to make this? Thx
Link102
18
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 19th Apr 2010 19:19
did you really have to post this twice?

the dbpro forum would have been just fine.

Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 20th Apr 2010 18:47
If it's 2D, then you could load in a long image, a load of hills for instance, then check the pixel height along the whole image, and store that in an array. If you grab the Y height at each X location then you can use that to work out character collision against the terrain. It might take a little bit more memory to do it this way, but you get full control over the graphics, and collision detection with ground heights is practically no strain on the processor. You could even check height differences and use it for collision too, for left and right movement. Maybe the character can only climb a certain amount of pixels (4 for instance), so if the next Y height difference to the side of the character is more than 4 then they stop.

Another benefit in this sort of collision detection is that you can change it afterwards too. For example, if you made a motocross game, you can affect the collision to suit wheels, by checking each X location for a wheel shape instead of a single point. You could even affect the Y speed of the character so they keep momentum based on their last position - would be pretty effective in a fast platform or motocross game, like sonic maybe.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2023-01-29 05:06:09
Your offset time is: 2023-01-29 05:06:09