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.

Dark GDK / 2D Platformer walking up hills/slants

Author
Message
Neon Sheild
14
Years of Service
User Offline
Joined: 27th Aug 2010
Location: Mt. Olympus
Posted: 19th Jan 2011 05:42
Hey guys,

I'm making a simple 2D platformer, and I've got some code down, but there is an issue that I just can't seem to figure out. I have walking and jumping working on a flat, level surface. For jumping, I said that after jumping, if the character's Y-Value is less than or equal the ground's Y-Value, stop jumping. This works, but as I said, only on flat ground.

So basically, here are my two questions:
How could I check for the Y-Value of the ground of the slant and pass that value to the Y-Value of the character while simply walking up the slant?
How would I check to see where the character should stop falling when on a slant?

Any help is greatly appreciated. Thanks in advance!

Perhaps, I theoretically might possibly have potential to hypothetically maybe have the chance to attempt something.
haliop
User Banned
Posted: 19th Jan 2011 15:04
there are nomuros ways to approach this.

im working (actualyl stopeed workgin) on a 3D grid system.

the grid works only with values like
0,1,1,1,
0,1,2,3
0,4,5,6
0,1,4,5

and such.. where the first is the current "stage" or "area" , the second is X the third is Y the fourth is Z

if we are talking about a 2D grid , so just remove the Z value.

what does this gives?
for every tile , you store the Width and Height on a grid like the example here , and you keep checking for it unless the player is not moving , this way you always get "int CurrentHeight" or "int CurrentGroundHeight = grid[playerX,playerY] "
once you have this CurrentGroundHeight you can always know what is the current tile your character or any dynamic actor should be on.

if we are talking about slopes , then abvoiusly its a bit harder , the grid should work like this ,

if you have a slope , you calculate same as above but you also add or any math calculation (not so good at trigonemtry) the Angle of the slope, i dont remmber the math behind this one , check for Triangle and Static Geometry it shouldnot be such a problem.

again there are plent of ways to approach this , but using Static Geometry will do best as its the most accurate and fast to calculate.

i hoped i helped .
nadav

Login to post a reply

Server time is: 2024-11-19 14:53:37
Your offset time is: 2024-11-19 14:53:37