-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.lua
More file actions
43 lines (37 loc) · 1.13 KB
/
update.lua
File metadata and controls
43 lines (37 loc) · 1.13 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
function reset()
x, y = screenWMid, screenHMid
randomMap(squareW, screenW, screenH, screenWMid, screenHMid)
time= 0
end
function randomMap(squareW, screenW, screenH, screenWMid, screenHMid)
for i=1 , 500 do
ramdomSquare(i, squareW, screenW, screenH, screenWMid, screenHMid)
end
end
function ramdomSquare(i, squareW, screenW, screenH, screenWMid, screenHMid)
local rx = love.math.random (screenW / squareW) * squareW
local ry = love.math.random (screenH / squareW) * squareW
if collisionDetectionSquare( x, y, rx, ry, squareW) then
rx = love.math.random (screenW / squareW) * squareW
ry = love.math.random (screenH / squareW) * squareW
end
local r = rx*255/screenW
local g = ry*255/screenH
local b = love.math.random (255)
squares[i] = {rx, ry, r, g, b}
end
function changeSquare(squareW, screenW, screenH, screenWMid, screenHMid)
i = love.math.random(#squares)
ramdomSquare(i,squareW, screenW, screenH, screenWMid, screenHMid)
end
function changeColor(dt)
if time> 1 then
setRandomColor()
time= 0
end
end
function setRandomColor()
r = love.math.random (255)
g = love.math.random (255)
b = love.math.random (255)
end