Author Topic: Orbiting Planets  (Read 1268 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Orbiting Planets
« on: June 09, 2025 »
I reverse engineered an old program with the only sample
of sorting I found. It's easier to use and understand.
This is my first moving graphic. Just one axis and no perspective.
Up arrow - change direction/stop
Left arrow - random postion
Right arrow - change view
Down arrow - change colour/no colour

Code: [Select]
open window 640,512
x=320
y=256
ang=pi/180
rain=20
dim R(rain)
dim G(rain)
dim B(rain)
dim dir(rain)
dim dist(rain)
dim sp(rain)
dim x1(rain)
dim y1(rain)
dim size(rain)
dim order$(rain)

for a=1 to rain
R(a)=int(ran(200))
G(a)=int(ran(200))
B(a)=int(ran(200))
dir(a)=int(ran(360))
dist(a)=int(ran(15))*20+20
next a

shape=4
turn=2
col=1

keys=16
dim go(keys)
dim g(keys)

key=16
dim go1(key)

repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
c=peek("port1")

for a=1 to keys
if and(c,2^(a-1))<>0 go(a)=1
if go(a)=1 g(a)=g(a)+1
if g(a)>2 g(a)=2
if g(a)=2 go(a)=0
if and(c,2^(a-1))=0 g(a)=0
next a

for a=1 to key
if and(c,2^(a-1))<>0 go1(a)=1
if and(c,2^(a-1))=0 go1(a)=0
next a

if go(6)=1 shape=shape+1
if shape>4 shape=1
text 12,24,str$(shape)

if go(5)=1 turn=turn+1
if turn>4 turn=1

if go(7)=1 col=col+1
if col>2 col=1

for a=1 to rain
if turn=3 or turn=1 dir(a)=dir(a)+0
if turn=2 dir(a)=dir(a)+sp(a)
if dir(a)>359 dir(a)=0
if turn=4 dir(a)=dir(a)-sp(a)
if dir(a)<0 dir(a)=359
next a

for a=1 to rain
if shape=5 then
dir(a)=a*(360/rain)
dist(a)=200
endif
next a

for a=1 to rain
if go(8)=1 then
dir(a)=int(ran(360))
dist(a)=int(ran(230))+20
endif
next a

for a=1 to rain
order$(a)=str$(size(a))
next a

for k=1 to rain-1
for j=1 to rain-k

if order$(j)>order$(j+1) then

temp=size(j)
size(j)=size(j+1)
size(j+1)=temp

temp=R(j)
R(j)=R(j+1)
R(j+1)=temp

temp=G(j)
G(j)=G(j+1)
G(j+1)=temp

temp=B(j)
B(j)=B(j+1)
B(j+1)=temp

temp=dir(j)
dir(j)=dir(j+1)
dir(j+1)=temp

temp=dist(j)
dist(j)=dist(j+1)
dist(j+1)=temp

temp=x1(j)
x1(j)=x1(j+1)
x1(j+1)=temp

temp=y1(j)
y1(j)=y1(j+1)
y1(j+1)=temp

temp$=order$(j)
order$(j)=order$(j+1)
order$(j+1)=temp$

endif

next j
next k

for a=1 to rain
x1(a)=cos(dir(a)*ang)*dist(a)+320
y1(a)=sin(dir(a)*ang)*dist(a)+256
sp(a)=25/dist(a)
size(a)=(y1(a)/500)*3
next a

for a=1 to rain
if shape=1 line x,y to x1(a),y1(a)
if shape=2 then
if col=1 or col=2 then
setrgb 1,256,256,256
circle x1(a),y1(a),15
endif
if col=2 then
setrgb 1,R(a),G(a),B(a)
fill circle x1(a),y1(a),14
endif
endif
if shape=3 then
setrgb 1,256,256,256
text x1(a),y1(a),"*"
endif
if shape=4 then
fill circle x1(a),256,12*size(a)
if col=1 setrgb 1,0,0,0
if col=2 setrgb 1,R(a),G(a),B(a)
fill circle x1(a),256,11*size(a)
setrgb 1,256,256,256
endif
'if shape=5 line x1(a),10*size(a)+240 to x1(a),10*size(a)+270
next a

text 0,12,str$(dir(1),"###")

until (1=0)

« Last Edit: June 13, 2025 by bikemadness »
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.