-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.slua
More file actions
72 lines (58 loc) · 1.7 KB
/
main.slua
File metadata and controls
72 lines (58 loc) · 1.7 KB
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
--[[
-- $Id$
-- Very simple greeting program
-- Started if Scrupp is run without arguments
-- See Copyright Notice in LICENSE.txt
--]]
local width, height = 640, 480
scrupp.init("Scrupp", width, height, 32, false)
require "console"
local console = Console()
local tween = require "tween"
local random = math.random
-- load fonts
local fntVera = scrupp.addFont("fonts/Vera.ttf", 28)
local fntWinks = scrupp.addFont("fonts/Winks.ttf", 150)
-- generate images of letters and words
local lblWelcome = fntVera:generateImage("Welcome to")
local lblWelcomeConf = {
x = (width - lblWelcome:getWidth()) / 2,
y = 80,
color = {255, 255, 255, 0}
}
local lblScrupp = fntWinks:generateImage("Scrupp")
local lblScruppConf = {
x = (width - lblScrupp:getWidth()) / 2,
y = -140,
color = {190, 0, 0}
}
local lblInfo = fntVera:generateImage("Just change 'main.slua' to suit your needs!")
local lblInfoConf = {
x = width+10,
y = 350
}
-- configure animations
local function colorCycle()
tween(1500, lblScruppConf, {color = {random(255), random(255), random(255)}}, 'linear', colorCycle)
end
tween(3000, lblWelcomeConf, {color = {255, 255, 255, 255}}, 'inQuad',
tween, 3000, lblScruppConf, {y = 150}, 'outBounce',
tween, 3000, lblInfoConf, {x = (width - lblInfo:getWidth()) /2}, 'outExpo',
colorCycle)
main = {
render = function(dt)
tween.update(dt)
--lblWelcome:setAlpha(lblWelcomeConf.alpha)
lblWelcome:render(lblWelcomeConf)
--lblScrupp:setColor(lblScruppConf.color)
lblScrupp:render(lblScruppConf)
lblInfo:render(lblInfoConf)
console:render()
end,
keypressed = function(key, wchar)
key, wchar = console:keypressed(key, wchar)
if key == "ESCAPE" then
scrupp.exit()
end
end
}