daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Nov 18th, 2017 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. ply = {}
  2.  
  3. -- Static player vars
  4. ply.speed = 300
  5.  
  6. -- Dynamic player vars
  7. ply.x = love.graphics.getWidth()/2
  8. ply.y = love.graphics.getHeight()/2
  9. ply.rad = 0
  10.  
  11. ply.sprite = love.graphics.newImage("sprites/player.png")
  12.  
  13. function ply.update(dt)
  14.     if love.keyboard.isDown('w') then
  15.         ply.y = (ply.y - (ply.speed * dt))
  16.     elseif love.keyboard.isDown("s") then
  17.         ply.y = (ply.y + (ply.speed * dt))
  18.     end
  19.  
  20.     if love.keyboard.isDown("a") then
  21.         ply.x = (ply.x - (ply.speed * dt))
  22.     elseif love.keyboard.isDown("d") then
  23.         ply.x = (ply.x + (ply.speed * dt))
  24.     end
  25.  
  26. --  print("This fixes the choppyness")
  27.     ply.rad = math.atan2(love.mouse.getY() - ply.y, love.mouse.getX() - ply.x) + 1.5
  28. end
  29.  
  30. function ply.draw()
  31.     love.graphics.setColor(0, 0, 0)
  32.     love.graphics.draw(ply.sprite, ply.x, ply.y, ply.rad, 0.5, 0.5, ply.sprite:getWidth()/2, ply.sprite:getHeight()/2)
  33.  
  34.     love.graphics.setColor(0, 0, 255)
  35.     love.graphics.line(love.mouse.getX() - 5, love.mouse.getY(), love.mouse.getX() + 5, love.mouse.getY())
  36.     love.graphics.line(love.mouse.getX(), love.mouse.getY() - 5, love.mouse.getX(), love.mouse.getY() + 5)
  37. 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