Jump by ChrisGDK22nd Dec 2009 21:02
|
---|
Summary Code for a short jump. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com #include "SC_Collision.h" float camx = dbObjectPositionX(1); float camy = dbObjectPositionY(1); float camz = dbObjectPositionZ(1); bool Jumping = false; bool Falling = false; bool JumpingActivated = false; float currentypos = 0.0f; bool canclicknow = true; if (dbKeyState(DIK_SPACE) && canclicknow == true){ currentypos = 0.0f; currentypos = dbObjectPositionY(1); JumpingActivated = true; canclicknow = false; } if (JumpingActivated){ Jumping = true; JumpingActivated = false; } if (dbObjectPositionY(1) >= currentypos+70.0f){ Jumping = false; Falling = true; } if (Jumping){ dbMoveObjectUp(1, 4); } if (Falling){ dbMoveObjectDown(1, 4); } if (SC_ObjectCollision(1, 2)){ Falling = false; // dbPositionObject(1, camx, camy, camz); canclicknow = true; } |