summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-05-16 08:10:20 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-05-16 08:10:20 -0700
commit7d415c4958f584c031922ed77a3559d15bf2dc1b (patch)
tree1957ccc8a42de22778b639352b38d9091a4adf4d
parent8cd9ec2e98d27b414bc7cff3a5a98b0aad9099ce (diff)
downloaddyl8-7d415c4958f584c031922ed77a3559d15bf2dc1b.tar.gz
dyl8-7d415c4958f584c031922ed77a3559d15bf2dc1b.zip
Snapshot
-rw-r--r--camera.lua6
-rw-r--r--collisions.lua9
-rw-r--r--dyl.lua107
-rw-r--r--dyl.p810
-rw-r--r--entity.lua12
-rw-r--r--map.lua24
6 files changed, 140 insertions, 28 deletions
diff --git a/camera.lua b/camera.lua
index b2dcf4c..6062ee7 100644
--- a/camera.lua
+++ b/camera.lua
@@ -42,11 +42,9 @@ end
_cull_factor = 1/4
function Camera:render(entity)
screen_position = (entity.sprite_position or entity.position) - self.position
- if not screen_position:in_bounds(SCREEN * -_cull_factor, SCREEN * (1 + _cull_factor)) then
- return
+ if screen_position:in_bounds(SCREEN * -_cull_factor, SCREEN * (1 + _cull_factor)) then
+ entity:render(screen_position)
end
-
- entity:render(screen_position)
end
function Camera:new(tracking)
diff --git a/collisions.lua b/collisions.lua
index 04575c4..f57554e 100644
--- a/collisions.lua
+++ b/collisions.lua
@@ -1,14 +1,17 @@
-sw, sh = 8, 8
function is_colliding(a, b)
ax1, bx1 = a.position.x, b.position.x
- ax2, bx2 = ax1 + sw, bx1 + sw
+ ax2, bx2 = ax1 + SPRITE_DIMS.x, bx1 + SPRITE_DIMS.y
ay1, by1 = a.position.y, b.position.y
- ay2, by2 = ay1 + sh, by1 + sh
+ ay2, by2 = ay1 + SPRITE_DIMS.y, by1 + SPRITE_DIMS.x
return (ax1 < bx2 and ax2 > bx1
and ay1 < by2 and ay2 > by1)
end
function handle_collision(a, b)
+ if a.entity_type == Entities.Sword and b.entity_type == Entities.Player and b.equipped[a.id] == nil then
+ b:equip(a)
+ return
+ end
if a.damage and b.health then
if b:is_in_iframe() then
return
diff --git a/dyl.lua b/dyl.lua
index e0914bd..398a6f7 100644
--- a/dyl.lua
+++ b/dyl.lua
@@ -25,13 +25,40 @@ function slashing_particle(following)
return SlashingParticleBuilder:build()
end
+function fire()
+ FireBuilder = EntityBuilder:new(World)
+ function FireBuilder:transition_state()
+ end
+ FireBuilder:b_type(Entities.Fire)
+ :b_position(vec2(50, 45))
+ :b_sprite_position(vec2(50, 45))
+ :b_line_of_sight(vec2(1, 0))
+ :b_render_order(1)
+ :b_add_state(
+ States.Hot, {
+ animation = {
+ sequence = { 195, 196, 197, 198 }, dt = 0.20
+ }
+ }
+ )
+ :b_add_state(
+ States.Warm, {
+ animation = {
+ sequence = { 211, 212, 213, 214 }, dt = 0.20,
+ }
+ }
+ )
+ :b_state(States.Hot)
+ return FireBuilder:build()
+end
+
function enemy()
EnemyBuilder = EntityBuilder:new(World)
function EnemyBuilder:transition_state()
end
EnemyBuilder:b_type(Entities.Enemy)
:b_health(10)
- :b_position(vec2(30, 40))
+ :b_position(vec2(30, -40))
:b_sprite_position(vec2(30, 40))
:b_line_of_sight(vec2(1, 0))
:b_render_order(1)
@@ -68,8 +95,8 @@ function wife()
:b_line_of_sight(vec2(1, 0))
:b_render_order(2)
:b_collidable()
- :b_position(vec2(50, 50))
- :b_sprite_position(vec2(30, 30))
+ :b_position(vec2(42, 42))
+ :b_sprite_position(vec2(42, 42))
:b_add_state(
States.Idle, {
animation = {
@@ -107,8 +134,8 @@ function bow()
:b_add_state(
States.Drawn, {
animation = {
- pos_y = { sequence = { 81 }, dt = 1, reflect = vec2(false, true) },
- neg_y = { sequence = { 81 }, dt = 1 },
+ pos_y = { sequence = { 97 }, dt = 1, reflect = vec2(false, true) },
+ neg_y = { sequence = { 97 }, dt = 1 },
pos_x = { sequence = { 81 }, dt = 1 },
neg_x = { sequence = { 81 }, dt = 1, reflect = vec2(true, false) }
}
@@ -142,8 +169,7 @@ function sword()
end
SwordBuilder:b_type(Entities.Sword)
:b_line_of_sight(vec2(1, 0))
- :b_position(vec2(0, 0))
- :b_sprite_position(vec2(0, 0))
+ :b_position(vec2(-50, 20))
:b_render_order(0)
:b_collidable()
:b_add_state(
@@ -166,10 +192,60 @@ function sword()
}
}
)
- :b_state(States.Equipped)
- e = SwordBuilder:build()
- assert(e.states[States.Equipped])
- return e
+ :b_add_state(
+ States.Idle, {
+ animation = {
+ sequence = { 98 }, dt = 1
+ }
+ }
+ )
+ :b_state(States.Idle)
+ return SwordBuilder:build()
+end
+
+function block(pos, sprite)
+ BlockBuilder = EntityBuilder:new(World)
+ function BlockBuilder:transition_state()
+ end
+ BlockBuilder
+ :b_type(Entities.Block)
+ -- :b_line_of_sight(vec2(1, 0))
+ :b_render_order(2)
+ :b_collidable()
+ :b_position(vec2(pos))
+ :b_add_state(
+ States.Idle, {
+ animation = {
+ sequence = { sprite }, dt = 1
+ }
+ }
+ )
+ :b_state(States.Idle)
+ return BlockBuilder:build()
+end
+
+function door(pos)
+ return block(pos, 193)
+end
+
+function building(pos)
+ b = {
+ { 0, 0, 2, 0 },
+ { 1, 1, 1, 1 },
+ { 1, 3, 1, 1 }
+ }
+ for y = 1,3 do
+ for x = 1,4 do
+ v = pos + (vec2(x - 1, y - 1) * SPRITE_DIMS)
+ if b[y][x] == 1 then
+ block(v, 192)
+ elseif b[y][x] == 2 then
+ block(v, 194)
+ elseif b[y][x] == 3 then
+ door(v)
+ end
+ end
+ end
end
function player()
@@ -212,14 +288,17 @@ function player()
return PlayerBuilder:build()
end
+building(vec2(10, -90))
+
_enemy = enemy()
_sword = sword()
_wife = wife()
-_bow = bow()
+-- _bow = bow()
+_fire = fire()
_player = player()
-_player:equip(_sword)
+-- _player:equip(_sword)
-_walk_speed = 40 -- powerup increase?
+_walk_speed = 35 -- powerup increase?
function handle_input()
dpos = vec2(0, 0)
if btn(0) then dpos.x -= 1 end
diff --git a/dyl.p8 b/dyl.p8
index 2cfd619..610a367 100644
--- a/dyl.p8
+++ b/dyl.p8
@@ -47,12 +47,12 @@ __gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000990000000030005c00050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-04444000009a79000000300005cc0c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-04994000009aa900000880000511c150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000000030005c00050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+04444000000990000000300005cc0c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+04994000009a7900000880000511c150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
04444000009aa9000087880005111150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-004400000097a9000088880005111150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-00000000000990000008800000555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00440000000990000088880005111150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00000000000000000008800000555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00040000000400000000007004000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
diff --git a/entity.lua b/entity.lua
index e383b4f..849674e 100644
--- a/entity.lua
+++ b/entity.lua
@@ -4,8 +4,12 @@ Entities = {
Enemy = 2,
Bow = 3,
Particle = 4,
- Wife = 5
+ Wife = 5,
+ Fire = 6,
+ Door = 7,
+ Block = 8
}
+ -- TODO: Why are these all in one object. We should have like "SpriteStates", "FireStates", etc.
States = {
Walk = "walk",
Idle = "idle",
@@ -13,9 +17,13 @@ States = {
Equipped = "equipped",
Slashing = "slashing",
Drawing = "drawing",
- Drawn = "drawn"
+ Drawn = "drawn",
+ Hot = "hot",
+ Warm = "warm"
}
+SPRITE_DIMS = vec2(8, 8)
+
Entity = {}
Entity.__index = Entity
diff --git a/map.lua b/map.lua
new file mode 100644
index 0000000..87cb5f3
--- /dev/null
+++ b/map.lua
@@ -0,0 +1,24 @@
+_t = {
+ H = { name = "home", color = 11 },
+ C = { name = "current", color = 7, blink = true },
+ K = { name = "visited", color = 6 },
+ M = { name = "mystery", color = 2 },
+ R = { name = "restock", color = 9 },
+ E = { name = "empty", color = 0 }
+}
+
+RealMap = {
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.R, _t.E, _t.H, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E }
+}
+
+DisplayMap = {
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.E, _t.E, _t.H, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E },
+ { _t.E, _t.E, _t.E, _t.E, _t.E }
+} \ No newline at end of file