Skip to content

Commit

Permalink
Added pause action for dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
unternehmen committed Sep 15, 2017
1 parent 07e75d8 commit 5b3fe79
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 45 deletions.
13 changes: 9 additions & 4 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ All writing is by me, unternehmen!
All graphics were hand-made by me, unternehmen!

## Music
The music and sound effects were collected from the OpenGameArt.org website.
All of them had been released under the CC-0 license when this game was made:
The music and sound effects were collected from OpenGameArt.org and
Soundbible.com. All of them had been released under the CC-0 license
or were in the public domain when this game was made.

"city.mp3" is from "Atmospheric Puzzles" by legoluft:
https://opengameart.org/content/atmospheric-puzzles
Expand All @@ -30,5 +31,9 @@ All of them had been released under the CC-0 license when this game was made:
"primord.mp3" is "Ancient Fairytale" by Oddroom:
https://opengameart.org/content/ancient-fairytale

Sound effects are from "Atmospheric Interaction Sound Pack" by legoluft:
https://opengameart.org/content/atmospheric-interaction-sound-pack
Most sound effects are from "Atmospheric Interaction Sound Pack" by legoluft:
https://opengameart.org/content/atmospheric-interaction-sound-pack

The dial-up connection sound is by ezwa and is from soundbible.com:
http://soundbible.com/136-Dial-Up-Modem.html

54 changes: 37 additions & 17 deletions dialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local typingstate = {}
local waitingstate = {}
local choosingstate = {}
local fadingstate = {}
local pausingstate = {}

-- The default dialog state is "inactive".
dialog.currentstate = inactivestate
Expand All @@ -29,12 +30,6 @@ local function drawletterbox()
end


-- Inactive state
function inactivestate.draw()
drawletterbox()
end


-- Typing state

function typingstate.update()
Expand All @@ -46,6 +41,7 @@ function typingstate.update()
bloop:play()

if dialog.lettersshown == #dialog.currentmessage then
dialog.animationtimer = 0
dialog.currentstate = waitingstate
end
end
Expand All @@ -55,8 +51,6 @@ function typingstate.draw()
assert(dialog.currentmessage ~= nil, 'dialog.currentmessage is nil')
assert(dialog.lettersshown ~= nil, 'dialog.lettersshown is nil')

drawletterbox()

love.graphics.setFont(font)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.print(string.sub(dialog.currentmessage,
Expand All @@ -67,17 +61,22 @@ end

-- Waiting state

function waitingstate.update()
assert(dialog.animationtimer ~= nil, 'dialog.animationtimer is nil')

dialog.animationtimer = (dialog.animationtimer + 1) % 50
end

function waitingstate.draw()
assert(dialog.currentmessage ~= nil, 'dialog.currentmessage is nil')

drawletterbox()
assert(dialog.animationtimer ~= nil, 'dialog.animationtimer is nil')

love.graphics.setFont(font)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.print(dialog.currentmessage, 0, 90)

love.graphics.setColor(255, 255, 255, 255)
love.graphics.rectangle('fill', virtualwidth - 16, virtualheight - 16, 16, 16)
love.graphics.setColor(255, 255, 255, (255 / 25) * math.abs(dialog.animationtimer - 25))
love.graphics.rectangle('fill', virtualwidth - 5, virtualheight - 5, 3, 3)
end

function waitingstate.mousepressed(x, y, button, istouch)
Expand All @@ -92,8 +91,6 @@ end
function choosingstate.draw()
assert(dialog.choices ~= nil, 'dialog.choices is nil')

drawletterbox()

-- Draw the choices.
love.graphics.setFont(font)

Expand Down Expand Up @@ -140,6 +137,20 @@ function choosingstate.mousepressed(x, y, button, istouch)
end


-- Pausing state

function pausingstate.update()
requirethread()
assert(dialog.pausetimer ~= nil, 'dialog.pausetimer is nil')

if dialog.pausetimer == 0 then
coroutine.resume(dialog.thread)
else
dialog.pausetimer = dialog.pausetimer - 1
end
end


-- Fading state

function fadingstate.update()
Expand Down Expand Up @@ -174,8 +185,6 @@ end
function fadingstate.draw()
assert(dialog.fadeopacity ~= nil, 'dialog.fadeopacity is nil')

drawletterbox()

love.graphics.setColor(0, 0, 0, dialog.fadeopacity)
love.graphics.rectangle('fill', 0, 0, virtualwidth, virtualheight)
end
Expand Down Expand Up @@ -208,7 +217,10 @@ do
end

dialog.update = statecallerproc('update')
dialog.draw = statecallerproc('draw')
dialog.draw = function ()
drawletterbox()
runifdefined(dialog.currentstate.draw)
end
dialog.mousemoved = statecallerproc('mousemoved')
dialog.mousepressed = statecallerproc('mousepressed')
dialog.keypressed = statecallerproc('keypressed')
Expand Down Expand Up @@ -238,6 +250,14 @@ function dialog.choose(...)
return result
end

function dialog.pause(duration)
dialog.pausetimer = duration
dialog.currentstate = pausingstate
coroutine.yield()
dialog.pausetimer = nil
dialog.currentstate = inactivestate
end

function dialog.fadein(duration)
dialog.fadeopacity = 255
dialog.fadedirection = 'in'
Expand Down
1 change: 1 addition & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function love.load()
confirm = love.audio.newSource('sounds/confirm.wav', 'static')
bloop = love.audio.newSource('sounds/bloop.wav', 'static')
anchor = love.audio.newSource('sounds/anchor.wav', 'static')
dial = love.audio.newSource('sounds/dial.wav', 'static')
currentbgmusic = nil

-- debug font
Expand Down
55 changes: 31 additions & 24 deletions room-call.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,65 @@ end

function room.draw()
-- Draw Jyesula with the scanline effect.
love.graphics.setCanvas(scancanvas)
love.graphics.push()
love.graphics.scale(0.25, 0.25)
love.graphics.clear(0, 0, 0, 0)
if jyesulavisible then
love.graphics.setCanvas(scancanvas)
love.graphics.push()
love.graphics.scale(0.25, 0.25)
love.graphics.clear(0, 0, 0, 0)

love.graphics.draw(scanline, 0, scanlineoffset + 69)
love.graphics.draw(scanline, 0, scanlineoffset)
love.graphics.pop()
love.graphics.setCanvas()
love.graphics.setCanvas(canvas)
love.graphics.push()
love.graphics.scale(0.25, 0.25)
love.graphics.clear(0, 0, 0, 0)
love.graphics.setBlendMode('alpha')
love.graphics.draw(jyesula, 0, 0)
love.graphics.setBlendMode('multiply')
love.graphics.draw(scancanvas)
love.graphics.setBlendMode('alpha')
love.graphics.pop()
love.graphics.setCanvas()
love.graphics.draw(canvas, 0, 0)
love.graphics.draw(scanline, 0, scanlineoffset + 69)
love.graphics.draw(scanline, 0, scanlineoffset)
love.graphics.pop()
love.graphics.setCanvas()
love.graphics.setCanvas(canvas)
love.graphics.push()
love.graphics.scale(0.25, 0.25)
love.graphics.clear(0, 0, 0, 0)
love.graphics.setBlendMode('alpha')
love.graphics.draw(jyesula, 0, 0)
love.graphics.setBlendMode('multiply')
love.graphics.draw(scancanvas)
love.graphics.setBlendMode('alpha')
love.graphics.pop()
love.graphics.setCanvas()
love.graphics.draw(canvas, 0, 0)
end
end

local function introaction()
backdrop = love.graphics.newImage('images/comm.png')

currentbgmusic:setVolume(0.1)
dial:play()
dialog.fadein(200)
dialog.pause(400)
jyesulavisible = true
dialog.pause(20)
currentbgmusic:setVolume(1.0)

switchbgmusic(shipmusic)
say 'Do you have news, Agent?'

local result = choose('Uh...', 'Is your refridgerator running?',
'Apologies, wrong number.')

if result == 2 then
say '... I am disconnecting.'
say 'Please do your job, Agent.'
elseif result == 3 then
say 'Good luck, Agent.'
end

dialog.fadeout(200)

anchor:play()
rooms.enter(rooms.ship)
end

function room.enter()
scanlineoffset = 0
jyesulavisible = false

objects = {}

dialog.start(introaction)
end

return room
return room
Binary file added sounds/dial.wav
Binary file not shown.

0 comments on commit 5b3fe79

Please sign in to comment.