diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-05-06 08:34:18 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-05-06 08:37:50 -0700 |
| commit | b4cfed422d753bea585572c693b6d1bd8ef68f6e (patch) | |
| tree | 28fe21663cc2bd9f140edac67f889509dfa1f8f0 /entity.lua | |
| parent | 48491750e4ece19d2252592850b75d100afc2455 (diff) | |
| download | dyl8-b4cfed422d753bea585572c693b6d1bd8ef68f6e.tar.gz dyl8-b4cfed422d753bea585572c693b6d1bd8ef68f6e.zip | |
Fix health, make sword slashing particle closer
Diffstat (limited to 'entity.lua')
| -rw-r--r-- | entity.lua | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -44,8 +44,8 @@ function Entity:update(dt) self:update_sprite_position() if (self.equipped != nil) then parent = self - for id, entity in pairs(self.equipped) do - entity:equipped_from(parent) + for id, entityDist in pairs(self.equipped) do + entityDist.entity:equipped_from(parent, entityDist.distance) end end @@ -55,7 +55,7 @@ function Entity:update(dt) if self.life_time ~= nil then self.life_time -= dt end - if self.life ~= nil and self.life <= 0 then + if self.health ~= nil and self.health <= 0 then self:kill() end end @@ -116,7 +116,7 @@ function Entity:update_sprite_position() end function Entity:take_damage(direction, damage_spec) - if self.health == nil then + if self.health == nil or self:is_in_iframe() then return end self.health -= damage_spec.amount @@ -147,13 +147,13 @@ function Entity:integrate(dt) end end -function Entity:equip(that) - self.equipped[that.id] = that +_equipped_item_distance = 6 +function Entity:equip(that, dist) + dist = dist or _equipped_item_distance + self.equipped[that.id] = { entity = that, distance = dist } end -_equipped_item_distance = 6 function Entity:equipped_from(parent, dist) - dist = dist or _equipped_item_distance self.line_of_sight = vec2(parent.line_of_sight) offset = (parent.line_of_sight * dist) |
