daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Dec 19th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. player = {}
  2. player.x = 20
  3. player.y = 20
  4. player.sprite = 0
  5. player.speed = 3
  6.  
  7. function move()
  8.  player.moving = true
  9.  player.sprite += 1
  10.  if player.sprite > 3 then
  11.   player.sprite = 0
  12.  end
  13. end
  14.  
  15. --called once per update
  16. --at 30 fps
  17. function _update()
  18.   player.moving = false
  19.   if btn(0) then
  20.     player.x -= player.speed
  21.     move()
  22.   end
  23.   if btn(1) then
  24.     player.x += player.speed
  25.     move()
  26.   end
  27.   if btn(2) then
  28.     player.y -= player.speed
  29.     move()
  30.   end
  31.   if btn(3) then
  32.     player.y += player.speed
  33.     move()
  34.   end
  35.   if not player.moving then
  36.    player.sprite = 0
  37.   end
  38. end
  39.  
  40. --called once per visible frame
  41. function _draw()
  42.   cls()
  43.   spr(player.sprite, player.x, player.y)
  44. end
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