-
Notifications
You must be signed in to change notification settings - Fork 2
/
game.lua
93 lines (79 loc) · 2.16 KB
/
game.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
game = {
title = 'Kollum',
debug = false,
graphics = {
mode = { height = love.graphics.getHeight(), width = love.graphics.getWidth() }
},
fonts = {},
renderer = require('renderers/default'),
sounds = require('sounds'),
animations = require('animations'),
active_animations = {},
tile_size = {x = 48, y = 48},
version = require('version'),
url = 'http://ananasblau.com/kollum',
current_level = 1,
current_state = nil,
seed = 1
}
function game:createFonts(offset)
local font_file = 'fonts/Comfortaa-Regular.ttf'
self.fonts = {
lineHeight = (11 + offset) * 1.7,
small = love.graphics.newFont(font_file, 11 + offset),
regular = love.graphics.newFont(font_file, 13 + offset),
large = love.graphics.newFont(font_file, 16 + offset),
very_large = love.graphics.newFont(font_file, 20 + offset)
}
end
function game:setMode(mode)
self.graphics.mode = mode
love.graphics.setMode(mode.width, mode.height, mode.fullscreen or self.graphics.fullscreen)
if self.graphics.mode.height < 600 then
self:createFonts(-2)
else
self:createFonts(0)
end
end
function game:startMenu()
love.mouse.setVisible(true)
game.current_state = MainMenu()
end
function game:start()
game.stopped = false
love.mouse.setVisible(false)
game.current_state = MapState(game.current_level)
end
function game:hasNextLevel()
return true
end
function game:nextLevel()
if self:hasNextLevel() then
self.current_level = self.current_level + 1
end
game:start()
end
function game:finished(player, message, progress)
love.mouse.setVisible(true)
game.stopped = true
game.current_state = FinishScreen(player, message, progress)
end
function game:killed(player)
game:finished(player, _('You have lost :('), false)
end
function game.loadImage(image)
return love.graphics.newImage(image)
end
function game:newVersionOrStart()
if version and version.version and version.url then
game:newVersion(version.version, version.url)
else
game:startMenu()
end
end
function game:newVersion(version, url)
game.current_state = NewVersion(version, url)
end
function game:showCredits()
game.current_state = State(self, 'Credits', CreditsView())
end