classic starscape mod
Code: (Select All)
randomize timer
dim shared pi, d, zz, sw, sh
pi = 4*atn(1)
d = 700
zz = 2100
sw = 1280
sh = 720
type stype
x as double
y as double
z as double
end type
dim shared star(2000) as stype
type gtype
x as double
y as double
z as double
r as double
r1 as double
r2 as double
a1 as double
a2 as double
a3 as double
end type
dim shared galaxy(100) as gtype
screen _newimage(sw, sh, 32)
for i=0 to 2000
star(i).x = 5000*rnd-2500
star(i).y = 5000*rnd-2500
star(i).z = 5000*rnd-2500
next
for i=0 to 30
galaxy(i).x = 4000*rnd-2000
galaxy(i).y = 4000*rnd-2000
galaxy(i).z = 4000*rnd-2000
galaxy(i).r = 150*rnd
galaxy(i).r1 = rnd
galaxy(i).r2 = rnd
galaxy(i).a1 = 2*pi*rnd
galaxy(i).a2 = 2*pi*rnd
galaxy(i).a3 = 4*pi*rnd - 2.5*pi*rnd
next
do
cls
for i=0 to 2000
star(i).z = star(i).z - 100
if star(i).z < 0 then
star(i).x = 4000*rnd-2000
star(i).y = 4000*rnd-2000
star(i).z = 4000*rnd-2000
end if
x1 = star(i).x
y1 = star(i).y
z1 = star(i).z
for z0 = 0 to 3
pset (sw/2 + x1*d/(z1 + zz + z0*10), sh/2 - y1*d/(z1 + zz + z0*10)),_rgb(255 - 50*z0, 255 - 50*z0, 0)
next
next
for i=0 to 30
galaxy(i).z = galaxy(i).z - 100
if galaxy(i).z < -zz then
galaxy(i).x = 4000*rnd-2000
galaxy(i).y = 4000*rnd-2000
galaxy(i).z = 8000*rnd'-2000
galaxy(i).r = 10*rnd + 30
galaxy(i).r1 = rnd
galaxy(i).r2 = rnd
galaxy(i).a1 = 2*pi*rnd
galaxy(i).a2 = 2*pi*rnd
galaxy(i).a3 = 4*pi*rnd - 2.5*pi*rnd
end if
x1 = galaxy(i).x
y1 = galaxy(i).y
z1 = galaxy(i).z
r = galaxy(i).r
r1 = galaxy(i).r1
r2 = galaxy(i).r2
a1 = galaxy(i).a1
a2 = galaxy(i).a2
a3 = galaxy(i).a3
drawgalaxy x1, y1, z1, r, r1, r2, a1, a2, a3
next
_display
_limit 30
loop until _keyhit = 27
sleep
system
sub drawgalaxy(x1, y1, z1, r, r1, r2, a1, a2, u)
dim c as _unsigned long
for a=0 to u step 0.1
for i=0 to 0.001*r*(u - a)^3.5
x0 = (rnd - 0.5)*0.2*r*(u - a)
y0 = (rnd - 0.5)*0.2*r*(u - a)
z0 = (rnd - 0.5)*0.2*r*(u - a)
if x0*x0 + y0*y0 + z0*z0 < 2000 then
for k=0 to 1
x = x0 + r1*r*a*cos(a + k*pi)
y = y0 + r2*r*a*sin(a + k*pi)
z = z0 + 1
rot x, y, a1
rot y, z, a2
c = 255*(u - a)/2
rr = c + rnd*50
gg = 0.2*c + rnd*50
bb = 0
if rr < 0 then rr = 0
if gg < 0 then gg = 0
if bb < 0 then bb = 0
if rr > 255 then rr = 255
if gg > 255 then gg = 255
if bb > 255 then bb = 255
rr = rr - z1/100
gg = gg - z1/100
bb = bb - z1/100
pset (sw/2 + (x + x1)*d/(z + z1 + zz), sh/2 - (y + y1)*d/(z + z1 + zz)), _rgb(rr, gg, bb)
next
end if
next
next
end sub
sub rot(xx, yy, a)
x = xx
y = yy
xx = x*cos(a) - y*sin(a)
yy = x*sin(a) + y*cos(a)
end sub