Skip to main content
GameDev.net gamedev.net
🔒 Locked

Gravity and across platforms problem

Started by DevLiquidKnight Jul 31, 2002 at 5:36 PM 3 replies 900+ views
Original Post
DevLiquidKnight
DevLiquidKnight
[removed] [Edited by - DevLiquidKnight on February 14, 2007 9:23:39 AM]
Dies_Irae
Dies_Irae
Im sorry but i just cant figure out what your talking about


fatal error C1004: unexpected end of file found
Swedish: #Gamedev.se on EFNET
DevLiquidKnight
DevLiquidKnight
Well i have a loop that causes a force of graivty to be pushed down onto the player by increasing the players y value.

The problem is my collison detection causes it so if u walk into a wall or somthing you just STOP and cannot move.

I tried to fix this by making the user be moved up by decreasing its y value to make him be 1 pxile higher then the actual platform itself.

And im trying ot get it so he can walk across the platform left and right yet at the same time beable to jump ect.

The gravity and the pushing him up one pixle to make him above the actual platform causes this bouncing..
davepermen
davepermen
i''ll suggest to dive into states..

if(!colliding(pos+v2(0,1)) state = FALLING;
else state = STANDING;

switch(state) {
case FALLING:
case JUMPING:
vel += dt*gravity;
pos += dt*vel;
break;
case STANDING:
vel += dt*(keyright - keyleft);
pos += dt*vel;
break;
}

if you set state to STANDING you should set it to the correct position as well..

if user presses keyjump, you should set the state to jumping and velocity to some value..

i think that way you could solve your problems (at least, all old 2d games used states, and most 3dgames today do as well (bots of q3 and others))

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
Sneftel
Sneftel
I second daveperman''s suggestion. The other good aspect of this is that you can easily decide what sprite to use. You can have a standing character, a walking character, a falling character, etc.

Have you ever played the old Apogee game Commander Keen? Episodes 4 and on had a rich variety of positions for the main character to be in, which added greatly to the quality of the graphics.



Don''t listen to me. I''ve had too much coffee.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.