summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--collisions.lua42
-rw-r--r--dyl.lua5
-rw-r--r--dyl.p822
-rw-r--r--entity.lua2
-rw-r--r--util.lua2
5 files changed, 37 insertions, 36 deletions
diff --git a/collisions.lua b/collisions.lua
index feb138b..4b9c430 100644
--- a/collisions.lua
+++ b/collisions.lua
@@ -1,30 +1,30 @@
sw, sh = 8, 8
function is_colliding(a, b)
- ax1, bx1 = a.position.x, b.position.x
- ax2, bx2 = ax1 + sw, bx1 + sw
- ay1, by1 = a.position.y, b.position.y
- ay2, by2 = ay1 + sh, by1 + sh
- return (ax1 < bx2 and ax2 > bx1
- and ay1 < by2 and ay2 > by1)
+ ax1, bx1 = a.position.x, b.position.x
+ ax2, bx2 = ax1 + sw, bx1 + sw
+ ay1, by1 = a.position.y, b.position.y
+ ay2, by2 = ay1 + sh, by1 + sh
+ return (ax1 < bx2 and ax2 > bx1
+ and ay1 < by2 and ay2 > by1)
end
function handle_collision(a, b)
--- if b.typ == types.enemy then
--- --print(b.id,100,100)
--- end
+ if b.entity_type == Entities.Enemy then
+ print(b.id, b.id * 10, b.id * 10)
+ end
end
function run_collisions()
- collidable = filter(World, function (e) return e.collision end)
- for _ai, a in ipairs(collidable) do
- for _bi, b in ipairs(collidable) do
- if a.id == b.id then
- goto continue
- end
- if is_colliding(a, b) then
- handle_collision(a, b)
- end
- ::continue::
+ collidable = filter(_World, function(e) return e.collision end)
+ for _ai, a in pairs(collidable) do
+ for _bi, b in pairs(collidable) do
+ if a.id == b.id then
+ goto continue
+ end
+ if is_colliding(a, b) then
+ handle_collision(a, b)
+ end
+ ::continue::
+ end
end
- end
-end
+end \ No newline at end of file
diff --git a/dyl.lua b/dyl.lua
index 6a337cd..e379ae3 100644
--- a/dyl.lua
+++ b/dyl.lua
@@ -7,7 +7,7 @@ function spawn_slashing_particle(e)
-- transitions
slash_animation:equipped_from(e, _slash_animation_distance)
end
- return slash_animation:b_type(Entities.Enemy)
+ return slash_animation:b_type(Entities.Particle)
:b_line_of_sight(e.line_of_sight)
:b_position(vec2(e.position))
:b_sprite_position(vec2(position))
@@ -99,8 +99,9 @@ bow:b_type(Entities.Bow)
:build()
sword = entity()
+_attack_burst_sec = 0.200
function sword:transition_state()
- if button_just_pressed(5) and self.state == States.Equipped then
+ if button_just_pressed(5) and self.state == States.Equipped and self.state_stopwatch > _attack_burst_sec then
self:transition_to(States.Slashing)
spawn_slashing_particle(self)
elseif self.state == States.Slashing and self.state_stopwatch > _slashing_timer_sec then
diff --git a/dyl.p8 b/dyl.p8
index 423b331..2920e34 100644
--- a/dyl.p8
+++ b/dyl.p8
@@ -54,12 +54,12 @@ __gfx__
00000000000000000008800000555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00040000000400000000007000000070000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00504000005040000000075000000750000008e00005500005090000000900000000000000000000000000000000000000000000000000000000000000000000
-0050900005777900000075000000750000008e000055560000555550055555600000000000000000000000000000000000000000000000000000000000000000
-005040000500400000975000009750000058e0000006550000550000005500000000000000000000000000000000000000000000000000000000000000000000
-00504000005040000049000000490000006500000055500000500000005000000000000000000000000000000000000000000000000000000000000000000000
-00040000000400000400000004000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00040000000400000000007004000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00504000005040000000075000490000000008e00005500005090000000900000000000000000000000000000000000000000000000000000000000000000000
+0050900005777900000075000097000000008e000055560000555550055555600000000000000000000000000000000000000000000000000000000000000000
+005040000500400000975000000570000058e0000006550000550000005500000000000000000000000000000000000000000000000000000000000000000000
+00504000005040000049000000005700006500000055500000500000005000000000000000000000000000000000000000000000000000000000000000000000
+00040000000400000400000000000570060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000070000000000000000000800000000000050000000600000000000000000000000000000000000000000000000000000000000000000000
@@ -70,13 +70,13 @@ __gfx__
00000000000550000000000000090000060000000000000000500000000500000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00056000000600000000000000000000006000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000
+000c6000000600000000000000000000006000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000005650600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000560000000000005600000005665000000066000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000060000000000050000000066506060000056000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000650000005605000000000005000000000005600000000000000000000000000000000000000000000000000000000000000000000000000000000
+000000000005c0000000000005c00000005c650000000c6000000000000000000000000000000000000000000000000000000000000000000000000000000000
+000000000000600000000000500000000c6506060000056000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000c50000005c05000000000005000000000005c00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000056600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000600000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+000000000006000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/entity.lua b/entity.lua
index 56dcd74..caa5226 100644
--- a/entity.lua
+++ b/entity.lua
@@ -42,7 +42,7 @@ function Entity:b_sprite_position(vec)
return self
end
function Entity:b_type(entity_type)
- self.entity_type = type
+ self.entity_type = entity_type
return self
end
function Entity:b_equipped(equipped)
diff --git a/util.lua b/util.lua
index b73838a..2b84d85 100644
--- a/util.lua
+++ b/util.lua
@@ -45,7 +45,7 @@ end
function filter(a, pred)
filtered = {}
- for k, v in ipairs(a) do
+ for k, v in pairs(a) do
if pred(v) then
filtered[k] = v
end