Advertisement
Guest User

Spagheti Code Example

a guest
Nov 20th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. function enemy:draw(lx,ly)
  2.  
  3.     for i,v in ipairs( self.table ) do
  4.         love.graphics.setColor(255,255,255)
  5.         if (v.x == lx) and (v.y == ly) then
  6.             if v.hp > v.initialHP then v.hp = v.initialHP end ----- Quick hack to keep enemy T2 vamps at max health.
  7.                 if v.isTagged == false then
  8.                     if v.x < hero.x then
  9.                             if v.type >= 8 and v.type <= 12 and distance2enemy(i) > 3 then
  10.                                 animation:loopAnimation(1, 0.1, (v.x - map.x) *32, (v.y - map.y) *32, false )
  11.                         else
  12.                             love.graphics.draw(tile.mob[v.type],(v.x - map.x) *32, (v.y - map.y) *32)
  13.                         end
  14.                     else
  15.                         if v.type >= 8 and v.type <= 12 and distance2enemy(i) > 3 then
  16.                             animation:loopAnimation(1, 0.1, (v.x - map.x) *32, (v.y - map.y) *32, true )
  17.                         else
  18.                             love.graphics.draw(tile.mob[v.type],(v.x - map.x) *32, (v.y - map.y) *32,0,-1,1,32,0)
  19.                         end
  20.                     end
  21.                 else
  22.                     love.graphics.draw(v.TaggImg,(v.x - map.x) *32, (v.y - map.y) *32,0,-1,1,32,0)
  23.                 end
  24.             local scaleFactor = 1 - ( (100 - ( (100 * v.hp) / v.initialHP ) ) / 100 )
  25.             love.graphics.draw(hb_background, (v.x - map.x) * 32, (v.y - map.y) * 32 - 5)
  26.             love.graphics.draw(hb_foreground, (v.x - map.x) * 32, (v.y - map.y)  * 32 - 5, 0, scaleFactor  ,1)
  27.             if v.takingDamage == true then
  28.                
  29.                 enemy:spillBlood( v.s, (v.x - map.x) * 32, (v.y - map.y) * 32 )
  30.                 if animation:getCurrentFrame(2) == animation:getFrames(2) then
  31.                     v.takingDamage = false                 
  32.                 end
  33.             end
  34.         end
  35.  
  36.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement