-
Notifications
You must be signed in to change notification settings - Fork 2
/
scredits.lua
172 lines (103 loc) · 3.63 KB
/
scredits.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
-------------------------------------------------------------------------
-- [scredits.lua]
-- scredits
-- Credits Screen
--
-- scrolls though the credits in _M.credits, looping.
-- scrolling speed can be modified by changing _M.speedscale.
-------------------------------------------------------------------------
local Gamestate = require "lib.gamestate"
local soundmanager = require "lib.soundmanager"
local music = love.audio.newSource("sfx/credits.ogg", 'stream') -- long audio files should be streamed
music:setLooping(true)
local _M = Gamestate.new()
_M._NAME = "scredits"
Gamestate.credits = _M -- so Gamestate.switch() can find us.
-------------------------------------------------------------------------
-- the actual credits text, feel free to edit this.
_M.credits = [[
'Evolution!'
LOVE-Party 24 Jam team!
=======================
-= Francisco =-
(Coding and Music)
-= Lafolie =-
(Ideas & Graphics)
-= Textmode =-
(Coder and Huggler)
-= JustAPerson =-
(General Coder, part-time huggler)
-= Roybie =-
(Hugglee)
-= VividReality =-
(Jack-of-all-trades)
With special thanks to
=======================
-= Bartbes =-
(Sex Machine)
...And everyone that joined the Ludum Dare:
Keep being Awesome.
"Stay a while and listen" ;).
^_^
*Huggles*
]]
--------------------------------------------------------------------------
_M.speedscale = 2 -- how fast to scroll the credits.
local width, height = love.graphics.getMode( )
-- the colors we use.
local COLOR_NORMAL = {200, 200, 200}
local COLOR_TITLE = { 50, 50, 50}
local COLOR_SKIP = { 50, 50, 50}
local COLOR_FRAME = { 0, 0, 0}
--------------------------------------------------------------------------
function _M:enter()
self.time = 0 -- timer
self.font = love.graphics.newFont(height*0.03) -- main font
self.wrap = select(2, self.font:getWrap(self.credits, width)) -- wrap length for the credits
self.offset = 0 -- rendering offset for the credits
--audio
music:rewind()
music:play()
self.bg = love.graphics.newImage('gfx/MainMenu_BG.png')
end
--------------------------------------------------------------------------
function _M:draw()
local lg = love.graphics
local lt = love.timer
lg.setFont(self.font)
lg.setColor(255, 255, 255)
lg.draw(self.bg,0,0)
-- The actual credits
lg.setColor(COLOR_NORMAL)
lg.printf(self.credits, 0, self.offset, width, 'center')
-- Top and bottom letterboxing
lg.setColor(COLOR_FRAME)
lg.rectangle('fill', 0, 0, width, height*.1)
lg.rectangle('fill', 0, height*.9, width, height*.1)
-- Title
local msg = love.graphics.getCaption()
local center = (width - lg.getFont():getWidth(msg)) / 2
lg.setColor(COLOR_TITLE)
lg.print(msg, center, height*.025)
-- Skip message
local msg = "Press any button to skip."
local center = (width - lg.getFont():getWidth(msg)) / 2
lg.setColor(COLOR_SKIP)
lg.print(msg, center, height*.925)
end
--------------------------------------------------------------------------
function _M:update(dt)
self.time = self.time+(dt*self.speedscale)
local fh = self.font:getHeight()
self.offset = (height-((fh*self.time) % (fh*self.wrap+height)))
end
--------------------------------------------------------------------------
function _M:keypressed(key, unicode)
if key == 'enter' or key == 'return' or key == ' ' then
music:stop()
Gamestate.switch(Gamestate.main);
end
end
-------------------------------------------------------------------------
if _VERSION == "Lua 5.1" then _G[_M._NAME] = _M end
return _M