Log In  

Cart #rabhebesu-0 | 2021-06-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1


Hey there, I'm trying to make a dash similar to the celeste classic one. I just have no idea how to code it. I just want a dash similar to that happen when inputting left or right. I looked at the code in celeste classic but can't make heads or tails of it. Could someone help me out? Thanks.

P.S. I left in the cartridge I am referencing to in this post.

P#93497 2021-06-15 01:52 ( Edited 2021-06-15 01:53)

From what I can tell, it checks the dash button early, then if the dash button is pressed it check whether the player has any dashes available. If so, the game then check sets up the quickest bits: that a dash was used (for the purpose of winged strawberries I think), that the player has one less dash available, that the dash should last 4 frames and that the visual effects of the dash should last 10 frames. Next, the code does some space-optimized checks for what direction and sets the horizontal and vertical speed that the would be implied. The variables d_full and d_half are used to keep the speeds easy to keep track of. d_full is 5, so the speed of the dash would be 5 pixels per frame. d_half is multiplied by the square root of 2 approximated as that long decimal starting with .707... because that's how the trigonometry works out. Going diagonally at 5 pixels per frame would be the same as going to the side and then up or down at 5 * sqrt(2) pixels per frame. After that, the code sets up how the speed should change during the dash. Elsewhere in the code, the function "appr()" is defined, which seems to be short for "approach". That function is used to make a number change by an set amount unless doing so would pass what the number needs to end up being. For the dash, this is used to make the player's speeds change by the dash acceleration (which is 1.5) until it reaches twice the player's normal maximum speed. As an exception, the code also checks if the player is going up, in which case the vertical target is multipled by 3/4, probably to make it feel more like having to fight gravity. Then the normal physics are applied on top of that.

To summarize, when the player dashes, their speed is set to 5, then it decreases by 1.5 each frame for the dash effect and 0.15 each frame for the normal physics until it reaches 2 (which takes 4 frames). After the speed becomes 2, it decreases by 0.15 as normal until it reaches 1 (the normal maximum speed).

P#93540 2021-06-15 14:20

[Please log in to post a comment]