|
@@ -3,7 +3,8 @@ import sin, cos from math
|
3
|
3
|
import random from love.math
|
4
|
4
|
tau = math.pi * 2
|
5
|
5
|
|
6
|
|
-hw, hh = graphics.getWidth! / 2, graphics.getHeight! / 2
|
|
6
|
+local hw, hh
|
|
7
|
+-- hw, hh = graphics.getWidth! / 2, graphics.getHeight! / 2
|
7
|
8
|
|
8
|
9
|
class System
|
9
|
10
|
new: (opts={}) =>
|
|
@@ -23,11 +24,16 @@ mkGalaxy = ->
|
23
|
24
|
table.insert galaxy, System radius: i, offset: 0.2 + random! * (tau - 0.2)
|
24
|
25
|
for i = 1, 2 * math.min hw, hh
|
25
|
26
|
table.insert galaxy, System radius: i, offset: 0
|
26
|
|
-mkGalaxy!
|
|
27
|
+
|
|
28
|
+love.load = ->
|
|
29
|
+ love.window.setFullscreen true, "desktop"
|
|
30
|
+ hw, hh = graphics.getWidth! / 2, graphics.getHeight! / 2
|
|
31
|
+ mkGalaxy!
|
27
|
32
|
|
28
|
33
|
time = os.time!
|
|
34
|
+speed = 1
|
29
|
35
|
love.update = (dt) ->
|
30
|
|
- time += dt
|
|
36
|
+ time += dt * speed
|
31
|
37
|
for system in *galaxy
|
32
|
38
|
system\update time
|
33
|
39
|
|
|
@@ -36,13 +42,13 @@ dist2 = (a, b) ->
|
36
|
42
|
dy = a.y - b.y
|
37
|
43
|
return dx * dx + dy * dy
|
38
|
44
|
|
39
|
|
-currentSystem = galaxy[100]
|
40
|
45
|
love.draw = ->
|
41
|
46
|
graphics.translate hw, hh
|
42
|
47
|
graphics.scale 0.5, 0.5
|
43
|
48
|
for system in *galaxy
|
44
|
49
|
system\draw!
|
45
|
50
|
|
|
51
|
+ -- currentSystem = galaxy[100]
|
46
|
52
|
-- dynamic formula (more range further out)
|
47
|
53
|
-- d = math.max 10, 0.25^2 * dist2 currentSystem, {x:0, y:0}
|
48
|
54
|
-- for system in *galaxy
|
|
@@ -72,7 +78,8 @@ love.keypressed = (key) ->
|
72
|
78
|
if key == "escape"
|
73
|
79
|
love.event.quit!
|
74
|
80
|
elseif key == "r"
|
75
|
|
- -- currentSystem = galaxy[random(#galaxy)]
|
76
|
81
|
mkGalaxy!
|
77
|
|
-
|
|
82
|
+ elseif key == "="
|
|
83
|
+ speed *= 2
|
|
84
|
+ elseif key == "-"
|
|
85
|
+ speed /= 2
|