Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. player = { x = 200, y = 710, speed = 1510, img = nil}
  2.  
  3. --timers
  4. canShoot = true
  5. canShootTimerMax = 0.2
  6. canShootTimer = canShootTimerMax
  7.  
  8. -- store the image file
  9. bulletImg = nil
  10. --store bullet entity
  11. bullets = {} -- array of bullets being drawn and updated
  12. function love.load(arg)
  13.     player.img = love.graphics.newImage('assets/plane.png')
  14.     player.img = love.graphics.newImage('assets/bullet.png')
  15.    
  16. end
  17.  
  18. function love.update(dt)
  19.     --start with way to close
  20.     if love.keyboard.isDown('escape') then
  21.         love.event.push('quit')
  22.     end
  23.     if love.keyboard.isDown('left', 'a') then
  24.         if player.x > 0 then --binds us to
  25.         player.x = player.x - (player.speed*dt)
  26.     end
  27.     elseif love.keyboard.isDown('right','d') then
  28.     if player.x < (love.graphics.getWidth() - player.img:getWidth()) then
  29.         player.x = player.x + (player.speed*dt)
  30.  
  31.     end
  32. end
  33.  
  34.  
  35. end
  36.  
  37. function love.draw(dt)
  38.     love.graphics.draw(player.img, player.x, player.y)
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement