home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
ST_USER
/
1989
/
USER1089.MSA
/
LANDSCAP.LST
< prev
next >
Wrap
File List
|
1985-11-19
|
7KB
|
331 lines
Rem GFA Basic Landscape Creator
Rem By C.Stratford
Rem (c) Atari ST User
Dim A$(16)
Dim Hx%(4)
Dim Hy%(4)
Openw 0
Deffill 0,1,3
Rem Set palette
Setcolor 0,0,0,0
Setcolor 1,0,0,7
Setcolor 2,0,7,0
Setcolor 15,7,7,7
Rem Set default values
Size%=25
Plane%=4
Waterlevel%=0
Quake%=5
Rem Set menus
For I%=0 To 16
Read A$(I%)
Next I%
Menu A$()
Menu 15,2
On Menu Gosub Branch
Do
On Menu
Loop
Rem Branch routine
Procedure Branch
Menu Off
If A$(Menu(0))=" About Quake " Then
Alert 0,"Fault Line | Generator |Written by|C.Straford |",1,"Continue",Z
Endif
If A$(Menu(0))=" Simulate " Then
Gosub Simulate
Endif
If A$(Menu(0))=" Set Parameters " Then
Gosub Parameters
Endif
If A$(Menu(0))=" Save Picture " Then
Gosub Picsave
Endif
If A$(Menu(0))=" Quit " Then
Gosub Quit
Endif
If A$(Menu(0))=" Change depth " Then
Gosub Depthchange
Endif
Return
Rem Quit
Procedure Quit
Alert 3,"Are you absolutely certain|that you want to do this?",2," Yes | No ",Yesno%
If Yesno%=1 Then
Setcolor 0,7,7,7
Setcolor 15,0,0,0
Edit
Endif
Return
Rem Depth change
Procedure Depthchange
Gosub Change(*Waterlevel%,"waterlevel")
Gosub Display
Return
Rem Set Parameters
Procedure Parameters
Change$="|Do you wish to change this?"
M$="The current size for the|grid is:"+Str$(Size%)+Change$
Alert 2,M$,1,"Yes|No",Ans
If Ans=1
Gosub Change(*Size%,"grid size")
Endif
M$="The current number of|planes is:"+Str$(Plane%)+Change$
Alert 2,M$,1,"Yes|No",Ans
If Ans=1
Gosub Change(*Plane%,"number of planes")
Endif
M$="The current number of|fault lines is:"+Str$(Quake%)+Change$
Alert 2,M$,1,"Yes|No",Ans
If Ans=1
Gosub Change(*Quake%,"number of fault lines")
Endif
M$="The current|waterlevel is:"+Str$(Waterlevel%)+Change$
Alert 2,M$,1,"Yes|No",Ans
If Ans=1
Gosub Change(*Waterlevel%,"waterlevel")
Endif
Menu 15,2
Return
Rem Change
Procedure Change(Item%,Message$)
Rem save part of current screen
Get 30,80,290,132,Storage$
Rem Draw box to put text in
Deffill 1,1,1
Pbox 30,80,290,120
Deffill 0,1,1
Pbox 31,81,289,119
Deffill 0,1,1
Text 33,95,"What do you wish to change"
M$="the "+Message$+" to?"
Text 33,103,M$
Print At(5,14);
Input ">",Change%
*Item%=Change%
Rem Put original screen back
Put 30,80,Storage$
Return
Rem Saves picture in Neo format
Procedure Picsave
Fileselect "*.*","",Filename$
If Filename$<>"" Then
Rem Save colours
Rem May be a few extra colours in Neochrome
Rem as not all of the colour registers are cleared
Dpoke Xbios(2)-124,0
Dpoke Xbios(2)-122,&H7
Dpoke Xbios(2)-120,&H70
Dpoke Xbios(2)-94,&H777
For I=Xbios(2)-92 To Xbios(2)-1
Poke I,0
Next I
Bsave Filename$,Xbios(2)-128,32128
Endif
Return
Rem Simulate routine
Procedure Simulate
Hidem
Erase Map%()
Erase Totalmap%()
Cls
Co=0.866
Setcolor 2,0,7,0
Setcolor 1,0,1,7
Color 1
Rem Set up arrays used for storing landscape
Dim Map%(Plane%,Size%,Size%)
Dim Totalmap%(Size%,Size%)
Rem Clear arrays
Arrayfill Totalmap%(),0
Arrayfill Map%(),0
Cls
For K%=1 To Plane%
For I%=1 To Quake%
Rem Choose random fault line
X1=Rnd*Size%
X2=Rnd*Size%
Y1=Rnd*Size%
Y2=Rnd*Size%
While X1=X2
X1=Rnd*Size%
Wend
M=(Y2-Y1)/(X2-X1)
Y%=Int(Rnd*Size%)
X%=Int(Rnd*Size%)
C%=Y%-M*X%
Rem Choose which land mass moves up and which moves down
Value%=Random(101)
If Odd(Value%) Then
Updown%=-1
Else
Updown%=1
Endif
For X%=0 To Size%
L%=Int((M*X%)+C%)
For Y%=0 To Size%
Rem Shift landmasses up or down
If Y%>=L% Then
Map%(K%,X%,Y%)=Map%(K%,X%,Y%)+Updown%
Else
Map%(K%,X%,Y%)=Map%(K%,X%,Y%)-Updown%
Endif
Next Y%
Next X%
Next I%
Rem draw array in 3D plane
Cls
Print K%;"/";Plane%
Xscale=319/(Size%*(1+Co))
Yscale=179/Size%*0.5
Mscale%=5
Rem Draw lines across
For Y%=0 To Size%
Plot Y%*Co*Xscale,125-(Y%+Map%(K%,0,Y%))*Yscale
For X%=1 To Size%
Draw To (Y%*Co+X%)*Xscale,125-(Y%+Map%(K%,X%,Y%))*Yscale
Next X%
Next Y%
Rem Draw lines down
For X%=0 To Size%
Plot X%*Xscale,125-(Map%(K%,X%,0)*Yscale)
For Y%=0 To Size%
Draw To (Y%*Co+X%)*Xscale,125-(Y%+Map%(K%,X%,Y%))*Yscale
Next Y%
Next X%
Next K%
Rem Add planes together
For X%=0 To Size%
For Y%=0 To Size%
For K%=1 To Plane%
Totalmap%(X%,Y%)=Totalmap%(X%,Y%)+Map%(K%,X%,Y%)
Next K%
Totalmap%(X%,Y%)=Totalmap%(X%,Y%)*2/Plane%
Next Y%
Next X%
Gosub Display
Showm
Return
Rem Display planes
Procedure Display
Hidem
Deffill 3,1,3
Cls
For Y%=Size% Downto 0
For X%=0 To Size%
If X%=Size% Then
X1%=X%
Else
X1%=X%+1
Endif
If Y%=0 Then
Y1%=Y%
Else
Y1%=Y%-1
Endif
Rem Load arrays ready for the Polyfill/Polyline instructions
Hx%(0)=(Y%*Co+X%)*Xscale
Hy%(0)=125-(Y%+Totalmap%(X%,Y%))*Yscale
Hx%(1)=((Y1%)*Co+X%)*Xscale
Hy%(1)=125-((Y1%)+Totalmap%(X%,Y1%))*Yscale
Hx%(2)=((Y1%)*Co+(X1%))*Xscale
Hy%(2)=125-((Y1%)+Totalmap%(X1%,Y1%))*Yscale
Hx%(3)=(Y%*Co+(X1%))*Xscale
Hy%(3)=125-(Y%+Totalmap%(X1%,Y%))*Yscale
Hx%(4)=Hx%(0)
Hy%(4)=Hy%(0)
Polyfill 5,Hx%(),Hy%()
Polyline 5,Hx%(),Hy%()
If Totalmap%(X%,Y%)<Waterlevel% Then
Hy%(0)=125-(Y%+Waterlevel%)*Yscale
Hy%(1)=125-(Y1%+Waterlevel%)*Yscale
Hy%(2)=Hy%(1)
Hy%(3)=Hy%(0)
Hy%(4)=Hy%(0)
Deffill 2,1,3
Polyfill 5,Hx%(),Hy%()
Deffill 3,1,3
Endif
Next X%
Next Y%
Rem fill in gaps at edges
Deffill 3,1,3
For Y%=Size%-1 Downto 0
Hx%(0)=(Y%*Co+Size%)*Xscale
Hy%(0)=125-(Y%+Waterlevel%)*Yscale
Hx%(1)=((Y%+1)*Co+Size%)*Xscale
Hy%(1)=125-((Y%+1)+Waterlevel%)*Yscale
Hx%(2)=Hx%(1)
Hy%(2)=125-((Y%+1)+Totalmap%(Size%,Y%+1))*Yscale
Hx%(3)=Hx%(0)
Hy%(3)=125-(Y%+Totalmap%(Size%,Y%))*Yscale
Hx%(4)=Hx%(0)
Hy%(4)=Hy%(0)
Polyfill 5,Hx%(),Hy%()
Polyline 5,Hx%(),Hy%()
Next Y%
For X%=0 To Size%-1
Hx%(0)=X%*Xscale
Hy%(0)=125-Waterlevel%*Yscale
Hx%(1)=(X%+1)*Xscale
Hy%(1)=125-Waterlevel%*Yscale
Hx%(2)=Hx%(1)
Hy%(2)=125-Totalmap%(X%+1,0)*Yscale
Hx%(3)=Hx%(0)
Hy%(3)=125-Totalmap%(X%,0)*Yscale
Hx%(4)=Hx%(0)
Hy%(4)=Hy%(0)
Polyfill 5,Hx%(),Hy%()
Polyline 5,Hx%(),Hy%()
Next X%
Rem Blank out the filled edges to give picture appearence of a flat plane
Rem floating in space. The section can be removed
Rem <-- Cut Here
Deffill 0,1,3
Pbox 0,125-Waterlevel%*Yscale,640,200
Hx%(0)=Size%*Xscale
Hy%(0)=125-Waterlevel%*Yscale
Hx%(1)=(Size%*Co+Size%)*Xscale
Hy%(1)=125-(Size%+Waterlevel%)*Yscale
Hx%(2)=640
Hy%(2)=Hy%(1)
Hx%(3)=640
Hy%(3)=Hx%(0)
Hx%(4)=Hx%(0)
Hy%(4)=Hy%(0)
Polyfill 5,Hx%(),Hy%()
Rem Draw stars for decoration
For I%=1 To 40
X%=Random(639)
Y%=Random(199)
While Point(X%,Y%)<>0
X%=Random(639)
Y%=Random(199)
Wend
Plot X%,Y%
Next I%
Rem <-- Cut to here
Showm
Menu 15,3
Return
Rem Menu data
Rem Remember spaces, otherwise menus look untidy
Data Info
Data " About Quake "
Data -
Data -
Data -
Data -
Data -
Data ""
Data Options
Data " Simulate "
Data " Set Parameters "
Data " Save Picture "
Data " Quit "
Data ""
Data " Depth "
Data " Change depth "
Data ""