-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
102 lines (78 loc) · 2.32 KB
/
Copy pathmain.lua
File metadata and controls
102 lines (78 loc) · 2.32 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
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
require "field"
require "interface"
function love.run()
local f = love.graphics.newFont(20)
love.graphics.setFont(f)
local defaultColor = {r = 255, g = 255, b = 255}
love.graphics.setColor(defaultColor.r,defaultColor.g, defaultColor.b)
love.graphics.setBackgroundColor(0, 0, 0, 255)
gameStarted = false
if love.load then love.load(defaultColor) end
local dt = 0
-- Main loop time.
while true do
-- Process events.
if love.event then
love.event.pump()
for e,a,b,c,d in love.event.poll() do
if e == "quit" then
if not love.quit or not love.quit() then
if love.audio then
love.audio.stop()
end
return
end
end
love.handlers[e](a,b,c,d)
end
end
-- Update dt, as we'll be passing it to update
if love.timer then
love.timer.step()
dt = love.timer.getDelta()
end
-- Call update and draw
if love.update then love.update(dt) end
if love.graphics then
love.graphics.clear()
if love.draw then love.draw() end
end
if love.timer then love.timer.sleep(0.1) end
if love.graphics then love.graphics.present() end
end
end
function love.load(arg1)
local cell = { width = 15, heigth = 15, dist = 2}
local defaultColor = arg1
field = {size = {x = 20, y = 20 }}
Interface:load(350,100,100,20, defaultColor)
Field:load(cell.width, cell.heigth, cell.dist, field.size.x, field.size.y, defaultColor)
--Flags
mouseClicked = false
win = false
end
function love.update(dt)
gameStarted = Interface:update(mouseClicked)
Field:update(mouseClicked, gameStarted)
mouseClicked = false
end
function love.draw()
Field:drawField()
Interface:draw()
--if win then
--love.graphics.print("well done!!", 260, 360)
--end
end
-- Scan input signals
function love.mousepressed(x, y, button)
if button == 'l' then
mouseClicked = true
else
mouseClicked = false
end
end
function love.keypressed( key, unicode )
if key == 'escape' then
love.event.push('quit')
end
end