Advertisement

Jumping?

Started by June 09, 2005 03:43 AM
15 comments, last by Noxir 19 years, 8 months ago
Ok, now I just need to know the "if(space_was_released)" command, could anyone please help I just need this command to make it work

( this is how I'll do it )

if (keys[VK_SPACE])
{
if (max != 1)
{
p1y += 0.2f;
}
}

if (keys[VK_WAS_RELEASED?])
{
max = 1;
}
nvm i found it!! thanks all for help ^^

if(!keys[VK_ESCAPE])
{
max = 1;
}
:D:D:D:D::D:D:D:D:D:D::D:D
Advertisement
Windows sends both WM_KEYDOWN and WM_KEYUP commands... I suggest you use that. Escape isn't really meant to quit jumping...
for real man you need to read a book man. it seem to me that you have no idea what you supposed to do. But i will be generous and give you a function that will do it for you here it is.


void PlayerJump(float delta)
{
/*We will assume we have a variable called
Gravity,Player_Y,Velocity,FallingLimit*/
Gravity=-9.81f //Gravity is Contant
Velocity+=Gravity*delta;
Player_Y+=Velocity;
if(Player_Y>FallingLimit)Player_Y=FallingLimit-1;
}

//Hope that gives and Idea on How you need to Implemented
if you do not know how to declare those Variable then you are not supposed to be writting games. By the way GLFloat is the same as float
oops i wrote wrong, i ment VK_SPACE, not VK_ESCAPE ;) thanks anyway, ive already made it all myself :D

if (keys[VK_SPACE])
{
if(max != 1)
{
p1y += 0.2f;
}
}
if (!keys[VK_SPACE])
{
max = 1;
}
if (p1y >= 4.0f)
{
max = 1;
p1y -= 0.1f;
}

This topic is closed to new replies.

Advertisement