-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
124 lines (112 loc) · 3.87 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
local Dialove = require('Dialove')
function love.load()
canvas = love.graphics.newCanvas(384, 216)
canvas:setFilter('nearest', 'nearest')
dialogManager = Dialove.init({
--font = love.graphics.newFont('fonts/comic-neue/ComicNeue-Bold.ttf', 20),
--font = love.graphics.newFont('fonts/press-start-2p/PressStart2P-Regular.ttf', 16),
--font = love.graphics.newFont('fonts/seagram/Seagram tfb.ttf', 16),
font = love.graphics.newFont('fonts/proggy-tiny/ProggyTiny.ttf', 16),
--numberOfLines = 3,
--typingVolume = 0.1,
optionsSeparation = 10,
viewportW = canvas:getWidth(),
viewportH = canvas:getHeight(),
})
--dialogManager:setDebug(true)
local function randomText()
local texts = {
"Hey, haven't we met before? Your face certainly looks familiar to me.",
"I live a couple of blocks away, we just moved to the city and you the first person I talk to...",
"Yes, I'm getting transferred to that same school actually, I'll see you there!",
"Well, we just met but you seem like a nice guy so, yes, I guess it's ok to go for a drink.",
"Well, you turned out to be a jerk, please don't talk to me anymore.",
"I don't have a boyfriend... do you have a girlfriend?",
"Sorry, I think that crosses the line, maybe I should go...",
"Sure, I'll see you around!",
}
return texts[love.math.random(1, #texts)]
end
dialogManager:show({
title = 'Title Dialog 1',
text = 'Dialog 1: Press F to complete the dialog, Space bar to speed up and Enter to request the next one.',
position = 'top',
options = {
{
'Choose Dialog 2', function ()
dialogManager:show('Dialog 2: ' .. randomText())
dialogManager:push({text = 'Dialog 4: ' .. randomText(), autoHeight = true})
end
},
{
'Choose Dialog 3', function ()
dialogManager:show({text = 'Dialog 3: ' .. randomText(), options = {
{
'Choose Dialog 5', function ()
dialogManager:show('Dialog 5: ' .. randomText())
end
},
{
'Choose Dialog 6', function ()
dialogManager:show({text = 'Dialog 6: ' .. randomText(), numberOfLines = 7})
end
}
}})
end
}
}})
dialogManager:push('Dialog 7: ' .. randomText())
dialogManager:push({text = 'Dialog 8: ' .. randomText(), options = {
{
'Choose Dialog 9', function ()
dialogManager:show('Dialog 9: ' .. randomText())
dialogManager:push('Dialog 10: ' .. randomText())
dialogManager:push('Dialog 11: ' .. randomText())
dialogManager:push('Dialog 12: ' .. randomText())
end
},
{
'Choose Dialog 13', function ()
dialogManager:show('Dialog 13: ' .. randomText())
dialogManager:push({
title = 'Title',
text = 'Dialog 14: ' .. randomText(),
image = love.graphics.newImage('face.png')
})
end
}
}})
randomColor = {love.math.random() / 2, love.math.random() / 2, love.math.random() / 2}
love.graphics.setBackgroundColor(randomColor)
end
function love.update(dt)
dialogManager:update(dt)
end
function love.draw()
love.graphics.setCanvas{canvas, stencil = true}
love.graphics.clear()
dialogManager:draw()
love.graphics.setCanvas()
love.graphics.draw(canvas, 0, 0, 0, love.graphics.getWidth() / canvas:getWidth(), love.graphics.getHeight() / canvas:getHeight())
end
function love.keypressed(k)
if k == 'return' then
dialogManager:pop()
elseif k == 'f' then
dialogManager:complete()
elseif k == 'space' then
dialogManager:faster()
elseif k == 'down' then
dialogManager:changeOption(1) -- next one
elseif k == 'up' then
dialogManager:changeOption(-1) -- previous one
end
if k == 'escape' then
love.event.quit()
end
end
function love.keyreleased(k)
if k == 'space' then
dialogManager:slower()
end
end