Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Geometry Dash - Jump length and turn
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
I'm trying to make a geometry dash game, and I can't figure out how to make the player turn. This game is a scrolling game, and the player xy doesn't change. I want the player to turn when jumping, but I don't know how to change the player jumping 180 degrees and 90 degrees.
These are one of the scripts of the player (the player only turns when jumping because the platform would move for that). I would be pleased if someone has a way of landing of platforms without turning 180 degrees.
These are one of the scripts of the player (the player only turns when jumping because the platform would move for that). I would be pleased if someone has a way of landing of platforms without turning 180 degrees.
- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
The simplest reason I get on mind by looking at he post is that rotating 13 times by 13.8461538462 degree makes 13 * 13.8461538462 = 180.0000000006… exactly 180.
Edit: I tried to change the value from 13.8461538462 to 6.923076923076923, but I had to delete game over broadcasts and then it turned only 90 degrees.
Edit: I tried to change the value from 13.8461538462 to 6.923076923076923, but I had to delete game over broadcasts and then it turned only 90 degrees.
Last edited by KaaBEL_sk (Sept. 24, 2023 08:04:28)
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
Thank you KaaBEL_sk, that makes the player turn more slowly. Sorry, but there's one more question. I want the player to turn 90 degrees and 180 degrees, depending on the platform it jumps on. Do you have any ideas?
- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
What kind of platform types do you mean?
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
Like the ones in geometry dash, the ones floating.
- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
I don't play geometry dash and don't remember whether platforms vhange the jump, but from youtube video I played frame by frame it seems the player starts rotating at the beggining of jump and jumpig on flat is enough to turn exactly 180 degrees, other times the jump or also when it falls down from platform, the players starts rotating as usuall but land earlier on edge (not:
This is one of the aspect of creting the project. The features must be understand and thought on how it actually works in code.
I will try to come up with good explation for the math that is used related to the rotating, but it might take some time to put in post.
) , then it finds the shortest direction for rotating to ‘not on edge’ direction.
This is one of the aspect of creting the project. The features must be understand and thought on how it actually works in code.
I will try to come up with good explation for the math that is used related to the rotating, but it might take some time to put in post.
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
I didn't know that players always jump 180 degrees. Thank you for helping me out!
- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
I didn't know that players always jump 180 degrees. Thank you for helping me out!OnlyMianly when lending on the same hight on which the jump started. Edited, because theoretically in longer jump it would continue to rotare to 270, 360… degrees
Last edited by KaaBEL_sk (Sept. 24, 2023 09:55:26)
- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
The math should be simpler:
Let's start with 180° rotation for flat jump. You use
It's done in main loop ín platform sprite atIt might be at least thing to try using starting velocity -21, because then at the top it stops with velocity 0 instead of 1 so it goes back in same steps lamds exactly to 0.
Here comes the undone easy math, but harder to do. When the player lands earlier or later then surface on surface it rotates back knowing by calculating mod 90 with which the correct rotation is checked, by comparing to 0. From the other values to get direction of the shortest angle just compare it in half with 45° each loop until it's near enought to mod 90 being zero, bcause it will probably overshoot with 13.846… to other side. For that you can check direction of shortest angle again and round rotation to mod 90 if it's the other side.
Let's start with 180° rotation for flat jump. You use
You found working that the jump on flat happens in 13 loops (or they can be also called cycles, because it's actually the separate frames when all currently running code is executed (runned) in specifiic order and stage displays the result after the execution). I would like to count that and see if we can get number of 13 loop by following the code execution.
It's done in main loop ín platform sprite at
First movement forward is applyed then, if variable “jump?” is true It sets velocity to -20 and starts adding 3 with the same loop. The jump ends in loop when the vertical movement would collide with ground. So the platforms positions go 0 - 20 = -20 for position and increasing velocity -20 by 3 to -17, but lets write down only loop order (n-th.) velocity (v) at the begginig of loop and y position (p) after movement:
1. v:-20 p:-20, 2. v:-17 p:-37, 3. v:-14 p:-51, 4. v:-11 p:-62, 5. v:-8 p:-70, 6. v:-5 p:-75, 7. v:-2 p:-77, (here we slowed down and player starts falling) 8. v: 1 p:76, 9. v: 4 p:-72, 10. v: 7 p:-65, 11. v: 10 p:-55, 12. v: 13 p:-42, 13. v: 16 p:-26, 14. v: 19 p:-7, 15. v: 21 p: 14, which is the last one touching the ground but it's ending with 14. And for some reason it's not 13 steps.
Here comes the undone easy math, but harder to do. When the player lands earlier or later then surface on surface it rotates back knowing by calculating mod 90 with which the correct rotation is checked, by comparing to 0. From the other values to get direction of the shortest angle just compare it in half with 45° each loop until it's near enought to mod 90 being zero, bcause it will probably overshoot with 13.846… to other side. For that you can check direction of shortest angle again and round rotation to mod 90 if it's the other side.
The problem here is the rotating back needs to be turned on when it isn't landed on surface.
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
I know theoretically it will continue to rotate, but I want to make “geometry dash” and not the theoretical jump, so rotating 180 degrees would make it. Thanks!!
- AppleTheo
-
8 posts
Geometry Dash - Jump length and turn
I changed the script a little, and fixed it. I commented #11 (the one on top of this) before I knew you were making a script for me, sorry
Could you try looking at my project again and fix where I should (if you can)?

- KaaBEL_sk
-
100+ posts
Geometry Dash - Jump length and turn
The problem is with rotating which shuld be happening together within y-position-update, which now is done either after or before it in player sprite. Because as the player's edge rotates towards the platform in fall and touches it. If it's checked in the same loop/myblock with falling and jumping into ‘sealing’ of platform (y-pos.-update) it won't do game over. In that moment it has to handle the y position's and rotation's collision. And because rotating is in diferrent sprite than y-position collision you could use I changed the script a little, and fixed it. I commented #11 (the one on top of this) before I knew you were making a script for me, sorryCould you try looking at my project again and fix where I should (if you can)?
Then after both were checked and the player landed on platform, the math from script where I showed calculation of shortest angle to mod 90 rotation, can be used there. Else it's falling/jumping in air which is at that moment done for curent loop.
And no problem it wasn't much of script (reather the essay wall of text that took long to write xD), I do like to not spoil the script making ‘fun’. It just needs to find own system to structure the code and make it well readable/understandable, reffering to also managing diving scripts into sprites (everything in one sprite vs. one sprite for each thing). Once you get them right the code will start making sense and especially for physics, which I did not work with yet myself much as it's fairly complicated.
- Discussion Forums
- » Help with Scripts
-
» Geometry Dash - Jump length and turn