-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.lua
173 lines (141 loc) · 3.5 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
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
173
function love.load()
-- Includes
--[[
love.filesystem.require("lua/button.lua")
love.filesystem.require("lua/resources.lua")
love.filesystem.require("lua/states.lua")
love.filesystem.require("lua/menu.lua")
love.filesystem.require("lua/game.lua")
--]]
love.filesystem.require = require
love.line_rough = "rough"
love.line_smooth = "smooth"
love.align_center = "center"
love.align_left = "left"
love.align_right = "right"
love.draw_fill = "fill"
love.draw_line = "line"
--ColorMode mode
love.color_modulate = "modulate"
love.color_replace = "replace"
--
function love.graphics.newColor(r, g, b, a)
--return tColor
tRGBa = {}
if not r or not g or not b then
print("There is some argument pass with nil, ues the default instead.")
tRGBa = {255, 255, 0, 125}
return tRGBa
end
table.insert(tRGBa, r)
table.insert(tRGBa, g)
table.insert(tRGBa, b)
if a then
table.insert(tRGBa, a)
end
return tRGBa
end
--[[
function love.graphics.getColor()
tRGBa = {}
local r, g, b, a = love.graphics.getColor()
table.insert(tRGBa, r)
table.insert(tRGBa, g)
table.insert(tRGBa, b)
if a then
table.insert(tRGBa, a)
end
return tRGBa
end
function love.graphics.setColor(tRGBa)
love.graphics.setColor(tRGBa.r, tRGBa.g, tRGBa.b, tRGBa.a)
end
--]]
--[[
function love.graphics.setColorMode(mode)
if mode == 0 or mode == nil then
mode = ""
end
if type(mode) == "string" then
love.graphics.setColorMode(mode)
else
mode = "modulate"
love.graphics.setColorMode(mode)
end
end
--]]
function love.audio.newMusic(file)
return love.audio.newSource(file)
end
function love.audio.newSound(file)
return love.audio.newSource(file)
end
--[[
function love.graphics.draw(text, x, y, r, sx, sy)
--print(type(text))
--print(text:type())
if type(text) == "string" then
love.graphics.print(text, x, y, r, sx, sy)
elseif type(text) == "number" then
love.graphics.print(""..text, x, y, r, sx, sy)
elseif type(text) == "userdata" then
print(text)
love.timer.sleep(100)
text = "error string!"
love.graphics.print(text, x, y, r, sx, sy)
--love.timer.sleep(100)
love.graphics.draw(text, x, y)
--love.graphics.print("what's this userdata??", x, y, r, sx, sy)
else
love.graphics.print("what's this??", x, y, r, sx, sy)
end
end
--]]
--[[test
text = love.graphics.newImage("img/current_logo.png")
love.graphics.draw(text)
love.timer.sleep(10000)
--]]
require("lua/button.lua")
require("lua/resources.lua")
require("lua/states.lua")
require("lua/menu.lua")
require("lua/game.lua")
-- Variables
debug = false
audio = true -- whether audio should be on or off
state = Menu.create() -- current game state
-- Setup
--love.graphics.setBackgroundColor(color["background"])
love.audio.play(music["menu"], 0)
--love.audio.setVolume(0.3);
-- randomize
math.randomseed(os.time())
end
function love.draw()
state:draw()
end
function love.update(dt)
--delay(33)
state:update(dt)
love.timer.sleep(1)
end
function love.delay(fps)
if (fps > 50) then
fps = fps + (fps / 10) - 5
end
local toSleep = 2 / fps - love.timer.getDelta()
if toSleep > 0 then
love.timer.sleep(toSleep * 1000)
end
end
function love.mousepressed(x, y, button)
state:mousepressed(x,y,button)
end
function love.keypressed(key)
if key == love.key_f4 and (love.keyboard.isDown(love.key_ralt) or love.keyboard.isDown(love.key_lalt)) then
--love.system.exit()
love.event.push("q")
end
state:keypressed(key)
end