diff options
Diffstat (limited to 'dyl.lua')
| -rw-r--r-- | dyl.lua | 107 |
1 files changed, 93 insertions, 14 deletions
@@ -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 |
