-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsstory.lua
136 lines (89 loc) · 3.43 KB
/
sstory.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
-------------------------------------------------------------------------
-- [sstory.lua]
-- sstory
-- story Screen
--
-- scrolls though the story in _M.sstory, looping.
-- scrolling speed can be modified by changing _M.speedscale.
-------------------------------------------------------------------------
local Gamestate = require "lib.gamestate"
local soundmanager = require "lib.soundmanager"
local _M = Gamestate.new()
_M._NAME = "sstory"
Gamestate.story = _M -- so Gamestate.switch() can find us.
-------------------------------------------------------------------------
-- the actual story text, feel free to edit this.
_M.credits = [[
'Evolutius'
Background Story
=======================
Life, life is a continuing loop of events.
Life evolves, based on these events.
Do these evolutions make life easier?
If you think of an evolution in the sense that it's an upgrade.
It does.
This game is all about evolving, upgrading.
Making life easier.
But beware, when prey evolve their defense,
hunters evolve their offense.
This also will repeat itself,
the loop of events of life.
How long will you survive?
How far will you evolve?
]]
--------------------------------------------------------------------------
_M.speedscale = 1.5 -- 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
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
Gamestate.switch(Gamestate.main);
end
end
-------------------------------------------------------------------------
if _VERSION == "Lua 5.1" then _G[_M._NAME] = _M end
return _M