home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
501-525
/
apd511
/
starfield.amos
/
starfield.amosSourceCode
Wrap
AMOS Source Code
|
1999-12-26
|
3KB
|
141 lines
Rem AMOS expanding starfield by Sarv Engelhardt, 1990
Screen Open 0,320,256,16,Lowres
Flash Off : Curs Off : Cls 0
Hide
' number of stars N
N=30
Colour 1,$888 : Colour 2,$999 : Colour 3,$AAA
Colour 4,$EEE : Colour 5,$DDF : Colour 6,$FF0
Dim C(N),X(N),Y(N),SX(N),SY(N)
Global DX,DY
'set up initial star positions and colours
For I=0 To N
X(I)=Rnd(320) : Y(I)=Rnd(256) : C(I)=Rnd(5)+1
Next I
' calcuate shifts for each star and store in sx(),sy()
For I=0 To N
STARSHIFT[X(I),Y(I)]
SX(I)=DX : SY(I)=DY
Next I
Double Buffer
Autoback 0
Screen Swap : Wait Vbl
'show initial star field
For I=0 To N
Plot X(I),Y(I),C(I)
Next I
' zoom!
Do
Cls 0 : Wait Vbl
For I=0 To N
'check if star goes off screen edge and replace it with
'a new one near the centre if it does
If X(I)>320 or Y(I)>256 or X(I)<0 or Y(I)<0
X(I)=Rnd(120)+100 : Y(I)=Rnd(120)+68
STARSHIFT[X(I),Y(I)]
SX(I)=DX : SY(I)=DY
End If
Add X(I),SX(I) : Add Y(I),SY(I)
Plot X(I),Y(I),C(I)
Next I
Screen Swap : Wait Vbl
Loop
Show : Edit
Procedure STARSHIFT[X,Y]
DX=0 : DY=0
P1#=0.02 : P2#=0.48 : P3#=1.0 : P4#=2.2 : P5#=30.0
If X>155 and X<165 : Goto EX : End If
If Y>123 and Y<133 : Goto EX : End If
AX#=X-160.0 : AY#=Y-128.0
R#=AX#/AY#
EX:
CX=X-160 : CY=Y-128
If CX>=-5 and CX<=5 and Y>=128
DX=0 : DY=3
Pop Proc
End If
If CY>=-5 and CY<=5 and X>=160
DX=3 : DY=0
Pop Proc
End If
If CX>=-5 and CX<=5 and Y<128
DX=0 : DY=-3
Pop Proc
End If
If CY>=-5 and CY<=5 and X<160
DX=-3 : DY=0
Pop Proc
End If
If X>=160 and Y<=128
If R#>=-P2# and R#<-P1#
DX=1 : DY=-3
Pop Proc
End If
If R#>=-P3# and R#<-P2#
DX=2 : DY=-2
Pop Proc
End If
If R#>=-P4# and R#<-P3#
DX=3 : DY=-2
Pop Proc
End If
If R#>-P5# and R#<-P4#
DX=3 : DY=-1
Pop Proc
End If
End If
If X>160 and Y>128
If R#>=P1# and R#<P2#
DX=1 : DY=3
Pop Proc
End If
If R#>=P2# and R#<P3#
DX=2 : DY=2
Pop Proc
End If
If R#>=P3# and R#<P4#
DX=3 : DY=2
Pop Proc
End If
If R#>=P4# and R#<P5#
DX=3 : DY=1
Pop Proc
End If
End If
If X<160 and Y<128
If R#>=P1# and R#<P2#
DX=-1 : DY=-3
Pop Proc
End If
If R#>=P2# and R#<P3#
DX=-2 : DY=-2
Pop Proc
End If
If R#>=P3# and R#<P4#
DX=-3 : DY=-2
Pop Proc
End If
If R#>=P4# and R#<P5#
DX=-3 : DY=-1
Pop Proc
End If
End If
If X<160 and Y>128
If R#>=-P2# and R#<-P1#
DX=-1 : DY=3
Pop Proc
End If
If R#>=-P3# and R#<-P2#
DX=-2 : DY=2
Pop Proc
End If
If R#>=-P4# and R#<-P3#
DX=-3 : DY=2
Pop Proc
End If
If R#>=-P5# and R#<-P4#
DX=-3 : DY=1
Pop Proc
End If
End If
End Proc