new jump method

This commit is contained in:
Makussu 2023-10-05 10:52:14 +02:00
parent 73cb60941d
commit 40e00559c6

View File

@ -2,6 +2,8 @@
//- Start Screen //- Start Screen
//- Level Editor (click with mouse spawns or deletes tiles) //- Level Editor (click with mouse spawns or deletes tiles)
// - Hotkey to slide the window right and left // - Hotkey to slide the window right and left
//- Movement berechnen mit move = gravitation - speed
// - Jump als Zahl, die langsam kleiner wird
// jumping related // jumping related
float speed = 20; float speed = 20;
@ -138,12 +140,17 @@ void jumpToJumpheight() {
jumpheight = 0; jumpheight = 0;
} }
} }
// count down jumping cooldown
void cooldown() { float movement;
if (jumpcooldown > 0) { float jumpspeed;
jumpcooldown = jumpcooldown-1; void newJump() {
movement = gravitation - jumpspeed;
pos.set(pos.x, pos.y + movement);
if (jumpspeed > 0) {
jumpspeed--;
} }
} }
// actions for moving // actions for moving
void keyPressed() { void keyPressed() {
if (key == CODED) if (key == CODED)
@ -160,10 +167,10 @@ void keyPressed() {
pos.x = pos.x + direction.x * speed; pos.x = pos.x + direction.x * speed;
//} //}
} }
if (keyCode == UP && jumpcooldown == 0) if (keyCode == UP)
{ {
//if (directionY<0) { //if (directionY<0) {
jumpheight += 400; jumpspeed =+ 25;
//} //}
} }
// else if (keyCode == DOWN) // else if (keyCode == DOWN)