SHARE
TWEET

Untitled

a guest Apr 21st, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Init function, initializing the state information
  2. init = (state) => {
  3.   state.title = "NierPixel.com"
  4.   state.gravity = 0.2
  5.   state.player = {
  6.     x: 0,
  7.     y: 0,
  8.     flip:false,
  9.     dashing:false,
  10.     initialSpeed: 1,
  11.     speed: 1,
  12.     dx:0,
  13.     dy:0,
  14.     spr:0
  15.   }
  16. }
  17.  
  18. //Dash speed increase
  19. const standardDash = (player) => {
  20.   player.dashing = true
  21.   player.speed += 5
  22. }
  23.  
  24. //Standard Dash
  25.   if(input.selectPressed && player.dashing === false) {
  26.     standardDash(player);
  27.   } else {
  28.    //Reduce player speed to initial after dashing is complete
  29.     if(player.speed > player.initialSpeed) {
  30.       player.speed = clamp(player.speed - player.speed * (elapsed / 150), 1, 7)
  31.     } else {
  32.       player.dashing = false
  33.     }
  34.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top