-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstars.lua
41 lines (32 loc) · 852 Bytes
/
stars.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
stars = {}
function initStars (numStars)
stars = {}
for i=1, numStars do
stars[i] = newStar()
end
end
function updateStars ()
for _, star in pairs(stars) do
star:update()
end
end
function drawStars ()
for _, star in pairs(stars) do
star:draw()
end
end
function newStar ()
local s = {}
s.location = newVector(math.random(0, game.world_size.width), math.random(0, game.world_size.height))
s.glitter = math.random(60, 150)
function s:update ()
self.glitter = self.glitter + randomIntegerBetween(-5, 5)
self.glitter = math.max(60, math.min(150, self.glitter))
end
function s:draw ()
love.graphics.setColor(255,255,255, self.glitter)
--love.graphics.circle('fill', self.location.x*game.zoom, self.location.y*game.zoom, 1)
love.graphics.point(self.location.x*game.zoom, self.location.y*game.zoom)
end
return s
end