Created
April 11, 2019 02:23
-
-
Save KinoAR/87df0d68d3f1804aad84c04e15dbf08c to your computer and use it in GitHub Desktop.
Dash Script-8 Example important code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Init function, initializing the state information | |
init = (state) => { | |
state.title = "NierPixel.com" | |
state.gravity = 0.2 | |
state.player = { | |
x: 0, | |
y: 0, | |
flip:false, | |
dashing:false, | |
initialSpeed: 1, | |
speed: 1, | |
dx:0, | |
dy:0, | |
spr:0 | |
} | |
} | |
//Dash speed increase | |
const standardDash = (player) => { | |
player.dashing = true | |
player.speed += 5 | |
} | |
//Standard Dash | |
if(input.selectPressed && player.dashing === false) { | |
standardDash(player); | |
} else { | |
//Reduce player speed to initial after dashing is complete | |
if(player.speed > player.initialSpeed) { | |
player.speed = clamp(player.speed - player.speed * (elapsed / 150), 1, 7) | |
} else { | |
player.dashing = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment