-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgasman-voyager.lua
128 lines (122 loc) · 2.64 KB
/
gasman-voyager.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
117
118
119
120
121
122
123
124
125
126
127
128
m=math
-- my god it's full of stars
stars={}
starcount=400
armcount=2 -- ok, let's stick to 2
-- naming things is hard
swirliness=0.1
galaxysize=100
for i=1,starcount do
-- y variation that's greater
-- in the centre?
-- I think I want it to be more
-- flying saucer shaped
-- another gaussian distribution
-- trick?
-- I think that's doing it
radius=m.random(galaxysize)
-- how close it is to the middle
centrality=1-(radius/galaxysize)
thicness=40*centrality
dy=(
m.random()*thicness-thicness/2
+ m.random()*thicness-thicness/2
+ m.random()*thicness-thicness/2
)/2
arm=m.random(armcount)
armangle=arm*m.pi*2/armcount
-- ok, I think the distance from the
-- arm centre should be a sort of
-- gaussian normal distribution
-- and i don't know the formula for
-- that
-- but i do know that's what you get
-- if you add several random
-- numbers together, like throwing
-- N dice
armdeviation=(
m.random()+m.random()+m.random()
* centrality
)
-- ship it!
stars[i]={
radius, -- radius
armangle+armdeviation+swirliness*radius, -- angle
(galaxysize*1.5-radius)/50, -- dot size
dy, -- vertical variation
-- middle ones should be brighter
centrality*8+m.random(8) -- colour
}
end
bgstars={}
bgstarcount=400
for i=1,bgstarcount do
bgstars[i]={
m.random(240),m.random(136),
-- they shouldn't go all the way
-- to pink
m.random(8)
}
end
-- set palette
-- blue - cyan - white
-- so blue reaches 1 first
-- then green, then red
for i=1,15 do
t=i/15
-- masta_luke777 thinks it should
-- have a tinge of pink
-- so how about I make the green
-- and blue elements top out at
-- like 220 or something
-- yes, that's a nice amount of pink
poke(16320+i*3,t^4*191+64) --r
poke(16320+i*3+1,t*150+32) --g
poke(16320+i*3+2,t^0.25*150+32) --b
end
function TIC()
spin=time()/2400
twirl=time()/10000
cx=120
cy=68
cls()
-- i think i want to do a sort of
-- slow camera descent into the
-- galactic plane
camy=cy+35*m.cos(time()/10000)
-- maybe some background stars
-- for ambience...
for i=1,bgstarcount do
star=bgstars[i]
pix(
(star[1]-time()/70)%240,
(star[2]+camy)%136,
star[3])
end
for i=1,starcount do
star=stars[i]
x=m.sin(star[2]+spin)*star[1]
y=m.cos(star[2]+spin)*star[1]
z=y*2
x=x*m.sin(twirl)+z*m.cos(twirl)
-- time for some palette variation
circ(
x+cx,
y+camy+star[4],
-- I think some sort of perspective
-- scaling might be good
-- yeah, kinda subtle
-- but i think that's as far as
-- it should go...
star[3]+(z+100)/400,
star[5])
end
craft=time()/2000
x=m.sin(109+spin+craft)*80
y=m.cos(109+spin+craft)*50
circb(
x+cx,
y+camy,
2,15
)
end