void cMainGame::CheckInput()
{
//BUTTON PRESSES///////////
static bool Z;
///////////////////////////
//this just keeps the player from going through the floor, for now. primiative collision.
if(Player.mySprite.myY >= 396)
{
Player.myPhysics.vVelocity = 0;
Player.mySprite.myY = 396;
Player.myPhysics.jumping = false;
}
switch(GameMode)
{
//The Game is Running
case MainGame:
//Jump
if(dk.KeyPressed(DIK_Z))
{
if(Z == false)
if(Player.myPhysics.jumping == false)
{
Player.Jump(80);
}
Z = true;
}
else
{
Z = false;
}
break;
default: break;
};
//Makes the object jump based on physics
void cObject::Jump(int velocity)
{
myPhysics.jumping = true;
myPhysics.vVelocity = velocity;
}
//////////////////////////////////////////
//APPLIES PHYSICS//////////////
void cPhysics::ApplyPhysics(float &Xpos, float &Ypos, DWORD TimeDelta)
{
//if jumping
if(jumping)
{
//Terminal velocity
if(vVelocity > -100)
{
//Applies Gravity
vVelocity = vVelocity + (int)GRAVITY * TimeDelta;
}
//Moves object
Ypos = Ypos - (vVelocity / 10);
}
}
///////////////////////////////