tom_burgess

Hero Punch

Apr 29th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. if love.keyboard.isDown("z") then
  2.     hero.punch=1 -- the player is trying to punch
  3.     time.punch=time.punch+dt -- count downtime of z
  4.     -- block player from cheating by holding down z
  5.     if time.punch>hero.punchduration then
  6.         hero.punch=0 -- turn off punching ( in love.draw() )
  7.     else end
  8.     if time.punch>0.6 then -- if player keeps punch held
  9.         time.punch=0 -- reset timer after 0.6s
  10.     else end
  11. else
  12.     hero.punch=0 -- the player is not trying to punch
  13.     time.punch=0 -- reset when he releases the key
  14. end
Advertisement
Add Comment
Please, Sign In to add comment