-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.lua
116 lines (91 loc) · 1.68 KB
/
window.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
led.clear()
len = 100
dot = {}
dot.__index = dot
dots = {}
function dot:length()
return led.length( self.strip )
end
function dot:random()
local len
len = self:length()
return esp.random((len/2),len) / len
end
function dot:create()
local item = {}
setmetatable(item, dot)
item.strip = esp.random(3)
item.pixel = esp.random( item:length() )
item.speed = item:random()
item.color = color.palette(#dots)
if esp.bit() then
item.speed = -item.speed
end
dots[#dots+1] = item
return item
end
function dot:newstrip(dir)
self.strip = self.strip + dir
if self.strip >= 4 then
self.strip = 0
elseif self.strip < 0 then
self.strip = 3
end
if self.speed > 0 then
self.speed = self:random()
if self.strip == 0 or self.strip == 1 then
self.pixel = 0
else
self.pixel = self:length() - 1
end
else
self.speed = -self:random()
if self.strip == 0 or self.strip == 1 then
self.pixel = self:length() - 1
else
self.pixel = 0
end
end
end
function dot:update()
if self.strip == 2 or self.strip == 3 then
self.pixel = self.pixel - self.speed
else
self.pixel = self.pixel + self.speed
end
if self.speed > 0 then
if self.pixel >= self:length() then
self:newstrip(1)
elseif self.pixel < 0 then
self:newstrip(1)
end
else
if self.pixel >= self:length() then
self:newstrip(-1)
elseif self.pixel < 0 then
self:newstrip(-1)
end
end
end
function dot:render()
led.write(
self.strip,
self.pixel,
color.screen(
led.read(self.strip, self.pixel),
self.color
)
)
end
for i=0,15 do
dot.create()
end
function frame()
for i=0,3 do
led.sub(i, 0x101010)
end
for idx, item in ipairs(dots) do
item:update()
item:render()
end
end