-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
75 lines (59 loc) · 1.63 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
require "require"
Object = require "classic"
require.tree("components")
require.tree("gameobjects")
Director = require "scenes/director"
Basic = require "scenes/basic_scene"
local sounds ={}
local music
function play_sound(sound, setting)
if setting == "stream" and sound ~= "soviet-anthem.mp3" then
return
end
local s = sounds[sounds]
if not s then
s = love.audio.newSource(sound, setting or "static")
if setting == 'stream' then
if music then
music:stop()
end
music = s
music:setLooping(true)
end
sounds[sound] = s
end
love.audio.play(s)
end
function approach(current, target, delta)
return math.max(math.min(current + delta, target), current-delta)
end
function dist(x1, y1, x2, y2)
return ((x1 - x2)^2 + (y1 - y2)^2)^0.5
end
local main_canvas
function resize(s)
-- love.window.setMode(s*gw, s*gh)
-- sx, sy = s, s
end
function love.load()
love.graphics.setDefaultFilter('nearest', 'nearest')
love.graphics.setLineStyle('rough')
-- resize(2)
Director:start_with_scene(require "scenes/title"())
main_canvas = love.graphics.newCanvas(gw, gh)
end
function love.update(dt)
if Director:update(dt) then
love.event.quit()
end
end
function love.draw()
love.graphics.setCanvas(main_canvas)
love.graphics.clear(colors[1])
Director:render()
love.graphics.setCanvas()
love.graphics.setColor(255, 255, 255, 255)
love.graphics.setBlendMode('alpha', 'premultiplied')
love.graphics.draw(main_canvas, 0, 0, 0, sx, sy)
love.graphics.setBlendMode('alpha')
end