Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.