summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-05-06 08:34:18 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-05-06 08:37:50 -0700
commitb4cfed422d753bea585572c693b6d1bd8ef68f6e (patch)
tree28fe21663cc2bd9f140edac67f889509dfa1f8f0
parent48491750e4ece19d2252592850b75d100afc2455 (diff)
downloaddyl8-b4cfed422d753bea585572c693b6d1bd8ef68f6e.tar.gz
dyl8-b4cfed422d753bea585572c693b6d1bd8ef68f6e.zip
Fix health, make sword slashing particle closer
-rw-r--r--dyl.lua5
-rw-r--r--entity.lua16
2 files changed, 11 insertions, 10 deletions
diff --git a/dyl.lua b/dyl.lua
index 1517438..70325c3 100644
--- a/dyl.lua
+++ b/dyl.lua
@@ -30,7 +30,7 @@ function enemy()
function EnemyBuilder:transition_state()
end
EnemyBuilder:b_type(Entities.Enemy)
- :b_health(100)
+ :b_health(10)
:b_position(vec2(30, 40))
:b_sprite_position(vec2(30, 40))
:b_line_of_sight(vec2(1, 0))
@@ -124,13 +124,14 @@ function bow()
end
function sword()
+ _particle_distance = 4
_attack_burst_sec = 0.200
_sword_damage = { amount = 2, knockback = { magnitude = 200, time = 0.080 } }
SwordBuilder = EntityBuilder:new(World)
function SwordBuilder:transition_state()
if button_just_pressed(5) and self.state == States.Equipped and self.state_stopwatch > _attack_burst_sec then
self:transition_to(States.Slashing)
- self:equip(slashing_particle(self))
+ self:equip(slashing_particle(self), _particle_distance)
self.damage = _sword_damage
elseif self.state == States.Slashing and self.state_stopwatch > _slashing_timer_sec then
self.damage = nil
diff --git a/entity.lua b/entity.lua
index 449200e..54c9769 100644
--- a/entity.lua
+++ b/entity.lua
@@ -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)