-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
83 lines (73 loc) · 1.44 KB
/
main.lua
File metadata and controls
83 lines (73 loc) · 1.44 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
require "collision"
require "controller"
require "update"
require "draw"
function love.load()
setRandomColor()
failsound = love.audio.newSource"fail-sound.wav"
winsound = love.audio.newSource"win-sound.mp3"
gameRunning = 0
love.mouse.setVisible(false)
squareW = 40
screenW, screenH = love.graphics.getDimensions()
squares = {}
squareW = screenH / 27
score = 0
screenWMid, screenHMid = screenW / 2, screenH / 2
x , y = screenWMid, screenHMid
circleRadius = squareW / 4
speed = 100
timelimit = 0.1
time = timelimit + 1
randomMap(squareW, screenW, screenH, screenWMid, screenHMid)
end
function love.draw()
drawMenu (gameRunning)
drawGame(r, g, b, x, y, circleRadius, squareW, score, squares)
end
function love.update(dt)
time = time+ dt
keyboardControll(dt, speed)
if time > timelimit then
changeSquare(squareW, screenW, screenH, screenWMid, screenHMid)
time = 0
end
changeColor(dt)
updateCollision()
end
function love.keypressed(k)
if k == 'escape' then
if gameRunning == 1 then
gameRunning = 0
else
love.event.quit()
end
end
if k == 'r' then
reset()
end
if k == 'lshift' then
speed = speed * 3
end
if k == 'return' then
menu = 0
gameRunning = 1
end
end
function love.keyreleased(key)
if key == "lshift" then
speed = 100
end
end
function gameover()
failsound:play()
timelimit = 0.1
reset()
score = 0
end
function win()
winsound:play()
score = score + 1
timelimit = timelimit / 2
reset()
end