From: parking_turkeys Date: Thu, 9 Jul 2026 18:43:24 +0000 (-0400) Subject: is this how you make a parabola i dont think it is X-Git-Tag: broken~14 X-Git-Url: http://git.p-t.hackclub.app/?a=commitdiff_plain;h=8c2d40540dff18b55108bab799b7b61b26045fef;p=aichan-platformer.git is this how you make a parabola i dont think it is --- diff --git a/main.c b/main.c index aed67e4..68a7bbb 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,8 @@ #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 @@ -28,6 +30,8 @@ struct platform ground[] = { {{0,320}, {640, 160}} }; int ground_length = 1; +float injump = -1; +int jumpstart; //functions Vector2 handle_inputs(struct character *player); @@ -49,10 +53,11 @@ int main(void) 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; @@ -101,7 +106,8 @@ Vector2 handle_inputs(struct character *player) }; if (IsKeyDown(inputs[3])) { direction.x++; }; if (IsKeyDown(inputs[4])) { - direction.y--; + injump = 0; + jumpstart = player->position.y } return direction; }