atlantis/enemies/urchin.lua
Hugues Ross 6194c73614 Add simple combat mechanics
- Swing equipped knife with Z
2021-02-01 07:48:24 -05:00

40 lines
803 B
Lua

local physics = require("physics")
local urchin = {
}
function urchin.new(x, y)
return {
x = x,
y = y,
width = 12,
height = 12,
update = urchin.update,
draw = urchin.draw,
hurt = urchin.hurt,
sprite = love.graphics.newImage("sprites/urchin.png"),
value = 1,
}
end
function urchin.update(self, player, level, systems, dt)
if physics.boxCollide(self, player) then
player:hurt(1)
end
if player.attack_hitbox and physics.boxCollide(self, player.attack_hitbox) then
player:on_hit(self, systems)
end
end
function urchin.draw(self)
love.graphics.setColor(1, 1, 1)
love.graphics.draw(self.sprite, self.x, self.y);
end
function urchin.hurt(self)
self.dead = true
end
return urchin