-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
54 lines (48 loc) · 1.07 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
require("util")
local vector = require("libs/vector/vector")
local start = true
local width, height = love.graphics.getDimensions()
local N = width * height -- number of intersections on grid
local offx = 1 -- every freq pixels create a vector
local offy = 1 -- every freq pixels create a vector
local perlins = {}
local dv = {x = offx, y = offy}
love.load = function()
for i = 0, height-1 do
perlins[i] = {}
for j = 0, width-1 do
perlins[i][j] = perlin(j, i, dv)
end
end
end
love.update = function(dt)
if start then
for i = 0, height-1 do
for j = 0, width-1 do
perlins[i][j] = perlin(j, i, dv)
end
end
start = not start
end
end
love.draw = function()
for i = 0, height-1 do
for j = 0, width-1 do
color = perlins[i][j]
if color > 1 then
color = 1
elseif color < -1 then
color = -1
end
love.graphics.setColor(1, 1, 1, color)
love.graphics.points(j, i)
end
end
end
love.keypressed = function(key, code, isrepeat)
if key == "q" then
love.event.quit()
elseif key == "space" then
start = not start
end
end