#define MAXSPEED 300
#define GRAVITY 50
+//at x seconds in a jump, y = 16x^2 + groundheight
+
//structures
struct character {
Vector2 position; //top left corner iirc
{{0,320}, {640, 160}}
};
int ground_length = 1;
+float injump = -1;
+int jumpstart;
//functions
Vector2 handle_inputs(struct character *player);
while (!WindowShouldClose()) {
Vector2 direction = handle_inputs(&player);
// set velocity
+ player.velocity.x = 0;
+ player.velocity.y = 0;
move_x(&player, direction.x);
move_y(&player, direction.y);
- gravity(&player, ground, ground_length);
-
+ if (injump = -1) {gravity(&player, ground, ground_length);} else { injump += GetFrameTime(); player.position.y = jumpstart + powf(injump, 2) * 16 + 2 * injump;
//set position
move_character(&player, ground, ground_length, GetFrameTime());
//player.position.y += 1;
}; if (IsKeyDown(inputs[3])) {
direction.x++;
}; if (IsKeyDown(inputs[4])) {
- direction.y--;
+ injump = 0;
+ jumpstart = player->position.y
}
return direction;
}