Advertisement
HugoBDesigner

Bounce

May 22nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. function love.load()
  2.     orx = 200
  3.     ory = 300
  4.    
  5.     orw = 100
  6.     orh = 50
  7.    
  8.     timer = 0
  9.     maxtimer = 3
  10. end
  11.  
  12. function love.update(dt)
  13.     dt = math.min(dt, 1/30)
  14.    
  15.     timer = timer + dt
  16.     if timer >= maxtimer then
  17.         timer = timer - maxtimer
  18.     end
  19. end
  20.  
  21. function love.draw()
  22.     love.graphics.setLineWidth(1)
  23.     love.graphics.setColor(0, 55, 0, 255)
  24.     love.graphics.line(orx-orw, ory, orx+orw, ory)
  25.     love.graphics.line(orx, ory, orx, ory-orh)
  26.    
  27.     love.graphics.setColor(0, 255, 0, 255)
  28.     love.graphics.line(orx-3, ory, orx+3, ory)
  29.     love.graphics.line(orx, ory-3, orx, ory+3)
  30.    
  31.     love.graphics.setColor(255, 0, 0, 255)
  32.    
  33.     local factor = 1.5 - timer/maxtimer
  34.     love.graphics.circle("fill", orx + math.cos(math.pi*2*factor)*orw, ory - math.abs( math.sin(math.pi*2*factor) )*orh, 3, 16)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement