]> _ Git - aichan-platformer.git/commitdiff
is this how you make a parabola i dont think it is
authorparking_turkeys <roya1060wien@gmail.com>
Thu, 9 Jul 2026 18:43:24 +0000 (14:43 -0400)
committerparking_turkeys <roya1060wien@gmail.com>
Thu, 9 Jul 2026 18:43:24 +0000 (14:43 -0400)
main.c

diff --git a/main.c b/main.c
index aed67e4..68a7bbb 100644 (file)
--- 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;
 }