Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created April 11, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/87df0d68d3f1804aad84c04e15dbf08c to your computer and use it in GitHub Desktop.
Save KinoAR/87df0d68d3f1804aad84c04e15dbf08c to your computer and use it in GitHub Desktop.
Dash Script-8 Example important code
//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