Commits

josefnpat committed 0a36879

Adding spritesheet'd zombies, but can't get them working yet.

Comments (0)

Files changed (6)

denom/entitylib/east.png

Added
New image

denom/entitylib/entitylib.lua

   entitylib.data = {}
   entitylib.img = love.graphics.newImage("entitylib/enemy.png")
   entitylib.new_zombie_dt = 0
+  
+  entitylib.img_north = love.graphics.newImage("entitylib/north.png")
+  entitylib.img_south = love.graphics.newImage("entitylib/south.png")
+  entitylib.img_east = love.graphics.newImage("entitylib/east.png")
+  entitylib.img_west = love.graphics.newImage("entitylib/west.png")
+
+
 end
 
 function entitylib.random_zombie()
 
 function entitylib.draw()
   for _,v in ipairs(entitylib.data) do
+  
+  
+  if v.state == 1 then 
+    v.ani_north:draw(v.x-16, v.y-16) 
+  elseif playerlib.state == 2 then 
+    v.ani_south:draw(v.x-16, v.y-16)
+  elseif playerlib.state == 3 then 
+    v.ani_west:draw(v.x-16, v.y-16)
+  elseif playerlib.state == 4 then
+    v.ani_east:draw(v.x-16, v.y-16)
+  end 
+  
     love.graphics.draw(entitylib.img,v.x+maplib.tx,v.y+maplib.ty,0,1,1,16,16)
 --    love.graphics.rectangle("line",v.x+maplib.tx-16,v.y+maplib.ty-16,32,32)
   end
 end
 
 function entitylib.update(dt)
+
+  for i,v in ipairs(entitylib.data) do
+    if v.move == 1 then
+      v.ani_north:play()
+      v.ani_south:play()
+      v.ani_east:play()
+      v.ani_west:play()
+    else
+      v.ani_north:stop()
+      v.ani_south:stop()
+      v.ani_east:stop()
+      v.ani_west:stop()
+    end
+    v.ani_north:update(dt) 
+    v.ani_south:update(dt)
+    v.ani_east:update(dt)
+    v.ani_west:update(dt)
+  end
+
   entitylib.new_zombie_dt = entitylib.new_zombie_dt + dt
   if entitylib.new_zombie_dt > 0.2 then
     entitylib.new_zombie_dt = 0
   ent.range = math.random(400,1200)
   ent.speed = math.random(140,180)
   ent.skip = false
+  
+  ent.ani_north = newAnimation(entitylib.img_north, 32, 32, 0.2, 3)
+  ent.ani_south = newAnimation(entitylib.img_south, 32, 32, 0.2, 3)
+  ent.ani_east = newAnimation(entitylib.img_east, 32, 32, 0.2, 3)
+  ent.ani_west = newAnimation(entitylib.img_west, 32, 32, 0.2, 3)
+
+  ent.ani_north:setMode("loop") 
+  ent.ani_south:setMode("loop")
+  ent.ani_east:setMode("loop")
+  ent.ani_west:setMode("loop")
+  
   ent.run = function(self,dt,tx,ty)
     local direction = math.atan2(tx-self.x,self.y-ty)+math.pi/2
     newx = self.x-(math.cos(direction)*dt*self.speed)

denom/entitylib/north.png

Added
New image

denom/entitylib/south.png

Added
New image

denom/entitylib/west.png

Added
New image

denom/playerlib/playerlib.lua

   playerlib.y = 300
   playerlib.move = 0
   playerlib.state = 2 -- POKEMON REFRENCE MUCH?
-
-  playerlib.img_north = love.graphics.newImage("playerlib/north.png")
-  playerlib.img_south = love.graphics.newImage("playerlib/south.png")
-  playerlib.img_east = love.graphics.newImage("playerlib/east.png")
-  playerlib.img_west = love.graphics.newImage("playerlib/west.png")
   
   playerlib.sword = love.graphics.newImage("playerlib/sword.png")
   playerlib.width = playerlib.sword:getWidth()
   playerlib.height = playerlib.sword:getHeight()
+  
+  playerlib.img_north = love.graphics.newImage("playerlib/north.png")
+  playerlib.img_south = love.graphics.newImage("playerlib/south.png")
+  playerlib.img_east = love.graphics.newImage("playerlib/east.png")
+  playerlib.img_west = love.graphics.newImage("playerlib/west.png")
 
   playerlib.ani_north = newAnimation(playerlib.img_north, 32, 32, 0.2, 3)
   playerlib.ani_south = newAnimation(playerlib.img_south, 32, 32, 0.2, 3)