Commit b646ca03 authored by Delisa Mason's avatar Delisa Mason

feat: Make dialog dismissable

parent fa3ea5a6
......@@ -15,14 +15,12 @@ group {
map_draw("level01"),
sprite_draw("player", 210, 110, 10, 10),
sprite_scale("player", 1, 1, 8),
wait(2)
dialog(40, 10, "We are gonna crash!!"),
}
--[[group {
sprite_draw("name", x, y),
image_draw("name", x, y),
map_follow("sprite name"),
dialog(x, y, "hello there"),
wait(10),
anim_draw("name", x, y)
wait(10),
}]]
......@@ -5,6 +5,7 @@ local Camera = require 'lib.camera'
local SceneDSL = function()
local scene = {
done = false,
awaiting_dialog_keyreleased = false,
assets = {},
groups = {},
groupindex = 1,
......@@ -241,12 +242,13 @@ local SceneDSL = function()
end
function scene.dialog(x, y, text)
-- TODO: figure out what goes here
local directive = {await_dialog=true}
function directive:draw()
love.graphics.print(text, x, y)
end
return directive
return {
await_dialog=true,
context={text=text, x=x, y=y},
draw=function(_, ctx)
love.graphics.print(ctx.text, ctx.x, ctx.y)
end
}
end
-- Callbacks
......@@ -258,6 +260,7 @@ local SceneDSL = function()
function scene.update(dt)
local group = scene.groups[scene.groupindex]
group:update(dt)
scene.awaiting_dialog_keyreleased = group.await_dialog
if group.elapsed >= group.duration and group.await_dialog ~= true then
if scene.groupindex == #scene.groups then
scene.done = true
......
......@@ -22,6 +22,9 @@ function state:keydown(key, code)
end
function state:keyreleased(key, code)
if self.scene.awaiting_dialog_keyreleased and key == 'space' then
self.scene.dialogkeyreleased()
end
end
return state
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment