home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
476-500
/
apd496
/
yachting.amos
/
yachting.amosSourceCode
Wrap
AMOS Source Code
|
1986-08-03
|
16KB
|
512 lines
'
' *********************************************************************
' * LA OROYA presents: *
' * -------- written by Stephan Scholz -1993- *
' * *
' * >>> Y A C H T I N G <<< *
' * *
' * A sailing simulator on a lake, with a Vista generated background *
' * scroll. You are on your yacht, about to sail round a three-buoy *
' * course, competing against a computer-driven adversary. If you *
' * win two out of three laps, you are the champion. *
' * *
' * Controls: rudder - sail - spinnaker. (Click mouse on chevrons.) *
' * It's a fine day for sailing, with a 12 knot wind - Good luck! *
' * *
' *********************************************************************
'
Set Buffer 40 : Dim H(360,17) : Dim H#(360,2) : Dim BUOY(3,3) : Dim CLV(16)
Proc SAILDATA : Proc SCRNOBJLDR
Sam Play 1,1,3000 : Sam Play 2,1,4000
Proc SETTINGS : Proc COMMENCE
QHF=182 : QCR=360 : QMV=180 : QQV=90 : QFW=30 : QFR=2
QFF#=0.025 : QHR#=68.2
Do
For DHO=1 To 2
For HO=0 To 9
Add HOR,OSCI
Add A,OSCI*PITCH
HR#= Extension_4_01D0(0)
BACKX=HR#/QHR#
HH=HR#/QHF
WW=ANGW-HH
If WW<1 Then WW=WW+QCR
TK=Sgn(WW-QMV)
SIL=QMV-(SAIL*TK)
TI=QMV*TK
QWW=QMV-WW
VES=VE#*VE#
FAPWIND=(SWIND)+(VES)-QFR*(WIND*VE#*Cos(QWW))
APWIND#=Sqr(FAPWIND)
AWA=WW-(QQV-Acos((VE#*Sin(QWW))/APWIND#))
AWT=AWA-TI
INS=(AWT-SIL)*-TK
If INS<1 : SIL=AWT : INS=1 : End If
FAR=H(INS,15)
FSAIL=H(INS,14)*Abs(Sin(SIL))
PROP#=FSAIL*FAPWIND*H#(WW,SPA)
VE#=VE#-(Sgn(VE#-PROP#)*QFF#)
VE=Abs(VE#*QFW)
If Mouse Key<>0
CONTROL
Else
Add F,-Sgn(F)
End If
G=F+F*H(VE,1)
RUD=QMV-F
Add B,G
Extension_4_01A6 0,A,B,C
Extension_4_0100 0,VE
Add VE1,Sgn(H(WW1,13)-VE1)
Extension_4_01A6 1,A,B1,C
Extension_4_0100 1,VE1
Cls 0
Extension_4_0318
Extension_4_049E 1,BACKX,0,320,85 To 0,HOR
Screen Copy 2,0,0,320,66 To 0,0,139
Screen Copy 3,HH,0,H(HH,2),9 To 0,94,143
Locate 14,23 : Print SPIN$
Plot BX,SY,13 : Draw To H(VE,16),H(VE,17)
Plot H(AWA,3),H(AWA,4),7 : Draw To H(AWA,5),H(AWA,6)
Plot PX,PY,FAR : Draw To H(SIL,7),H(SIL,8)
Plot PX,RY,13 : Draw To H(RUD,11),H(RUD,12)
Plot CX1,CZ1,7 : Plot CX,CZ,13 : Plot HX,HZ,4
Screen Swap : Wait Vbl
Next HO
If VE#<0 Then VE#=0
If AWA=180 Then Add F,5
If Extension_4_0344(0)>0 Then CRASH
OSCI=-OSCI
SHIPS : ROBWIND
Next DHO
If ARRIBA>0 : Dec ARRIBA : Sam Play 8,2,3000 : Sam Play 4,2,6000
If ARRIBA=0
If SPA=2 : SPA=1 : SPIN$="v" : Sam Play 8,2,3000 : Sam Play 4,2,4000
Else
SPA=2 : SPIN$="^" : Sam Play 8,2,5000 : Sam Play 4,2,6000 : End If
End If
End If
Proc SCANNER
Sam Play 1,1,CH1 : Sam Play 2,1,CH2
Loop
Procedure SCANNER
Shared LX,LY,LZ,LX1,LZ1,CX,CZ,CX1,CZ1,MULT,HX,HZ,X6,Z6
LX= Extension_4_0114(0)
LZ= Extension_4_013C(0)
Extension_4_00EC 0,LX,LY,LZ
CX=59+LX/MULT : CZ=170-LZ/MULT
If CX>87 Then CX=87
If CX<31 Then CX=31
If CZ>198 Then CZ=198
If CZ<142 Then CZ=142
CX1=59+LX1/MULT : CZ1=170-LZ1/MULT
If CX1>87 Then CX1=87
If CX1<31 Then CX1=31
If CZ1>198 Then CZ1=198
If CZ1<142 Then CZ1=142
HX=59+X6/MULT : HZ=170-Z6/MULT
End Proc
Procedure CRASH
Shared LX,LY,LZ,LX1,LY1,LZ1,CHOCA,F,HR#,VE#,CRA,HH,HH1,CRA
Sam Play 15,3,4000
Inc CHOCA
N= Extension_4_0344(0)
CRA= Extension_4_0258(0,N)-HR#
F=40*-Sgn(CRA)
End Proc
Procedure SHIPS
Shared LX1,LX,LZ1,LZ,LY,LY1,A,B,B1,WW1,HH1,TK1,ANGW,RADIUS
Shared X5,Y5,Z5,X6,Y6,Z6,BO1,BO0,BUOY(),BCOUNT,B1COUNT,CHOCA
Shared WON,LOST,LAPS
LX1= Extension_4_0114(1)
LZ1= Extension_4_013C(1)
B1= Extension_4_0262(1,X5,Y5,Z5)
MIRA:
Extension_4_01A6 1,A,B1,C
HH1= Extension_4_01D0(1)/182
WW1=ANGW-HH1
If WW1<1 Then WW1=WW1+360
If WW1>180 Then WW1=360-WW1
TK1=182*Sgn(WW1-180)
HAUL=40+Rnd(5)
If WW1<HAUL
B1=B1+((Rnd(15)+HAUL)-WW1*TK1)
Goto MIRA
End If
If Extension_4_028E(1,X5,Y5,Z5)<RADIUS-1000
Inc B1COUNT
If BO1<3
Inc BO1 : X5=BUOY(BO1,1) : Y5=BUOY(BO1,2) : Z5=BUOY(BO1,3)
End If
End If
Extension_4_00EC 1,LX1,LY1,LZ1
If Extension_4_028E(0,X6,Y6,Z6)<RADIUS
Inc BCOUNT : Bell 50
If BO0<3
Inc BO0 : X6=BUOY(BO0,1) : Y6=BUOY(BO0,2) : Z6=BUOY(BO0,3)
End If
End If
If BCOUNT=3
Clear Key : Inc LOST : Bell 50
Locate 27,19 : Print "Collided:";CHOCA
Locate 27,20 : Print "You've lost."
If B1COUNT<3
Inc WON : Dec LOST
Locate 34,20 : Print "won!!"
End If
Screen Swap : Wait 150 : Inc LAPS
Locate 27,19 : Print "Laps won :";WON
Locate 27,20 : Print "Laps lost:";LOST
Screen Swap : Bell 60 : Wait 150
If LAPS<3
If WON<2
Locate 27,19 : Print "Get ready to"
Locate 27,20 : Print "race again. "
Screen Swap : Bell 45 : Wait 150
End If
End If
If LOST>1
Locate 27,19 : Print "Better luck "
Locate 27,20 : Print "next time..!"
Inc LAPS : Screen Swap :
Sam Play 15,5,8000 : Wait 67
Sam Play 15,6,7000 : Wait Key
If Key State(16) : End : End If
End If
If WON>1 : Locate 27,19 : Print "Well raced.."
Locate 27,20 : Print "Champion !!!"
Inc LAPS : Screen Swap :
Sam Play 4 : Wait Key
If Key State(16) : End : End If
End If
'you start the next round
BCOUNT=0 : B1COUNT=0
'new race
If LAPS>2 : LAPS=0 : WON=0 : LOST=0 : End If
'wind direction change
ANGW=ANGW+Rnd(90)-45
If ANGW<1 : ANGW=ANGW+360 : End If
If ANGW>360 : ANGW=ANGW-360 : End If
Proc DARK
Proc SETTINGS
Proc COMMENCE
End If
End Proc
Procedure ROBWIND
Shared ANGW,VE#,VE1,SV0,SV1,DSE,CH1,CH2
DSE= Extension_4_007E(0,1)
SV0= Extension_4_0258(0,1)/182
SV1= Extension_4_0258(1,0)/182
If SV0<0 Then Add SV0,360
If SV1<0 Then Add SV1,360
If DSE<10000
Add SV0,-ANGW
If Abs(SV0)<30
If VE#>0.5
VE#=VE#-0.5
CH1=3000*(1+VE#/32)
CH2=3000*(1+VE#/24)
Pop Proc
End If
End If
Add SV1,-ANGW
If Abs(SV1)<30
If VE1>20
Add VE1,-20
CH1=3000*(1+VE#/3)
CH2=3000*(1+VE#/4)
Pop Proc
End If
End If
End If
CH1=3000*(1+VE#/8)
CH2=3000*(1+VE#/10)
End Proc
Procedure CONTROL
Shared FOCK,SAIL,F,FM,SPA,SPIN$,ARRIBA
X=X Mouse/8 : Y=Y Mouse/8
If Y>28
If X>37
If F<FM : Inc F : Pop Proc : End If
Else
If F>-FM : Dec F : Pop Proc : End If
End If
End If
If X>40
If Y<26
If SAIL<90 : Inc SAIL : Sam Play 8,2,4000 : Sam Play 2,2,6000 : Pop Proc : End If
Else
If SAIL>0 : Sam Play 8,2,5000 : Sam Play 2,2,7000 : Dec SAIL : Pop Proc : End If
End If
End If
If X<32
Sam Play 8,2,5000 : Sam Play 2,2,3000 : ARRIBA=4
SPIN$="*"
End If
End Proc
Procedure SETTINGS
Shared LX,LX1,LY,LY1,LZ,LZ1,BUOY(),BO0,BO1,FURTHER,RADIUS,FACTOR
Shared X5,Y5,Z5,X6,Z6,Y6,SAIL,FM,SPA,SPIN$,VE,VE#,VE1
LX=FURTHER+12000
LY=200
LX1=FURTHER+14000
LY1=500
LZ=-FURTHER-20000
LZ1=-FURTHER-15000
Extension_4_00EC 0,LX,LY,LZ
Extension_4_01A6 0,0,0,0
Extension_4_00EC 1,LX1,LY1,LZ1
Extension_4_01A6 1,0,0,0
'areas behind each buoy to detect if ships have passed
' including pythagoras correction factor for last two buoys.
RADIUS=5000 : FACTOR=(Sqr((RADIUS*RADIUS)*2))-RADIUS
BUOY(1,1)=0 : BUOY(1,2)=0 : BUOY(1,3)=FURTHER+RADIUS
BUOY(2,1)=-FURTHER-RADIUS+FACTOR : BUOY(2,2)=0 : BUOY(2,3)=-FURTHER-RADIUS+FACTOR
BUOY(3,1)=FURTHER+RADIUS-FACTOR : BUOY(3,2)=0 : BUOY(3,3)=-FURTHER-RADIUS+FACTOR
'which buoy are they going for at start:
BO0=1 : BO1=1
'buoy homing indicators for each ship:
X5=BUOY(BO1,1) : Y5=BUOY(BO1,2) : Z5=BUOY(BO1,3)
X6=X5 : Y6=Y5 : Z6=Z5
'initial boom angles
SAIL=24
'maximum rudder angle
FM=20
'spinnaker stowed at start
SPIN$="v" : SPA=1
'no speed at start
VE=0 : VE#=0 : VE1=0
Pen 3
End Proc
Procedure SCRNOBJLDR
Shared FURTHER,MULT
'Load sound effects
Load "Yachting:Samples/Sea1.Abk"
'background landscape loading and preparation of extra long strip.
Screen Open 0,320,256,16,Lowres : Flash Off : Curs Off
Load Iff "Yachting:Iffs/Graph.Iff" : Wait Key
Load Iff "Yachting:Iffs/Back.Iff",0
Screen Open 1,960,86,16,Lowres : Flash Off : Curs Off : Get Palette 0
Screen Copy 0,0,0,320,85 To 1,0,0
Screen Copy 0,0,86,320,170 To 1,320,0
Screen Copy 0,0,171,320,256 To 1,640,0
Screen Hide 1 : Screen 0
Screen Display 0,,,320,205
'dashboard loading and copying to a storage screen
Load Iff "Yachting:IFFs/DashboardC.IFF"
Screen Open 2,320,66,16,Lowres : Flash Off : Curs Off
Screen Copy 0,0,139,320,256 To 2,0,0
'compass screen strip loading and preparation
Screen Open 3,440,32,16,Lowres : Flash Off : Curs Off
Screen Hide 2 : Screen 3
Load Iff "Yachting:Iffs/Brujula.IFF"
Screen Copy 3,0,10,225,21 To 3,180,0
Screen Hide 3 : Screen 0
Extension_4_0054 140 : Double Buffer : Autoback 0
Extension_4_04D6 "Yachting:objects"
Extension_4_0016 "buoy1"
Extension_4_0016 "buoy2"
Extension_4_0016 "buoy3"
Extension_4_0016 "yacht"
FURTHER=100000
MULT=FURTHER/16
Extension_4_0036 1,"yacht",FURTHER+15000,0,FURTHER-5000,0,0,0
Extension_4_0036 2,"buoy1",0,H,FURTHER,0,0,0
Extension_4_0036 3,"buoy2",-FURTHER,0,-FURTHER,0,0,0
Extension_4_0036 4,"buoy3",FURTHER,0,-FURTHER,0,0,0
For N=2 To 4
Extension_4_0328 N,0,0,0,0,700
Next N
Extension_4_0328 0,0,0,0,500,500
Extension_4_0328 1,0,0,0,1400,700
Extension_4_0328 1,1,0,0,-1400,700
Extension_4_0328 1,2,0,0,0,700
End Proc
Procedure SAILDATA
Shared PX,PY,BX,BY,RY,SY,NAN#,NIN#,NON#,H(),H#()
Shared WIND,SWIND,SAIL,ANGW,OSCI,HOR,PITCH
Extension_4_0548 : Degree : Curs Off : Flash Off : Paper 0 : Ink 0,9 : Cls 0
Pen 11 : Locate 0,6 : Print " La Oroya presents:" : Print : Print
Pen 4 : Print " * * * YACHTING * * *" : Print : Print
Pen 15 : Print " Greetings to Mad Max and Kid Blast" : Print : Print
Randomize Timer : WIND=12 : SWIND=WIND*WIND
'wind direction
ANGW=Rnd(360)
If ANGW=180 or ANGW=0 Then ANGW=ANGW+1
Pen 4 : Print " Wind direction:";ANGW;" deg. N" : Print
Print " Wind speed :";WIND;" Kts."
'Horizon oscillation and its relationship to ship's pitching
OSCI=1 : HOR=-12 : PITCH=72
'points on screen for navigation instruments:
PX=176 : PY=171 : BY=155 : RY=189 : BX=116 : SY=178
'lengths of pointers
NIN#=17 : NON#=19
For N=0 To 360
SN#=Sin(N)
CN#=-Cos(N)
'rudder effect depends on speed
H(N,1)=N/10
'compass instrument data:
H(N,2)=N+45
'main navigation instrument:
'apparent wind indicator data:
H(N,3)=PX+NON#*SN#
H(N,4)=PY+NON#*CN#
H(N,5)=H(N,3)+NIN#/3*SN#
H(N,6)=H(N,4)+NIN#/3*CN#
'boom position indicator data:
H(N,7)=PX+16*SN#
H(N,8)=PY+16*CN#
'jib position indicator data (unused in this version):
H(N,9)=PX+12*SN#
H(N,10)=BY+12*CN#
'rudder indicator data data:
H(N,11)=PX+7*SN#
H(N,12)=RY+7*CN#
'speed indicator data:
H(N,16)=BX+NON#*-SN#
H(N,17)=SY+NON#*-CN#
'working factor accounting for resistances multiplied by
'wave and wind resistance close hauled, or their help if
'running free. This is called if spinnaker is not up.
H#(N,1)=0.0007+(0.00014*CN#)
Next N
'data for automatic ships' speed depending on real wind direction
'based on modern yachtspeed graph (with spinnaker for aft winds):
Restore AUTOS
For N=30 To 180
Read A#
H(N,13)=A#*2.1
Next N
AUTOS:
Data 0,0,0,5,10,15,20,25,30,31
Data 32,36,40,44,46,50,53,55,58,60
Data 62,64,66,68,70,71,72,73,74,75
Data 76,77,78,79,80,80,81,81,82,82
Data 83,83,84,84,85,85,86,87,88,89
Data 90,91,92,93,94,95,96,97,98,99
Data 100,100,101,101,102,102,103,103,104,104
Data 105,105,106,106,107,107,108,108,109,109
Data 110,111,112,113,114,115,116,117,117,118
Data 118,119,119,120,120,121,121,122,122,123
Data 123,124,124,125,125,125,124,124,123,123
Data 122,122,121,121,120,120,119,118,117,116
Data 115,114,113,112,111,110,109,108,106,104
Data 102,100,98,96,94,92,90,88,86,84
Data 82,81,80,79,78,77,76,76,75,75,75
Restore SAILS
For N=0 To 180
Read A
H(N,14)=A
If N<10 Then H(N,15)=15 : Goto RAUS
If N<26 Then H(N,15)=7 : Goto RAUS
H(N,15)=6
RAUS:
Next N
'your sail efficiency data, depending on the angle of incidence
'of the wind. Between 10 and 25 deg. there is laminar flow, and
'sail efficiency lies between 89 and 100% for 15 to 22 degrees.
SAILS:
Data 0,0,0,0,0,0,0,0,0,0
Data 80,81,83,85,87,89,91,93,95,97
Data 98,99,100,99,98,97,70,70,70,70
Data 70,70,70,70,70,70,70,70,70,70
Data 70,70,70,70,70,70,71,71,72,72
Data 73,73,74,74,75,75,75,75,75,75
Data 75,75,75,75,75,75,75,75,75,75
Data 75,75,75,75,75,75,75,75,75,75
Data 75,76,77,78,79,80,80,80,80,80
Data 79,78,77,76,75,74,73,72,71,70
Data 69,68,67,66,65,64,63,62,61,60
Data 59,58,57,56,55,54,53,52,51,50
Data 49,48,47,46,45,44,43,42,41,40
Data 39,38,37,36,35,34,33,32,31,30
Data 29,28,27,26,25,24,23,22,21,20
Data 19,18,17,16,15,14,13,12,11,10
Data 9,8,7,6,5,4,3,2,1,0
Data 0,0,0,0,0,0,0,0,0,0,0
'The following factor is a percentage increase on h#(n,1)
'which controls resistance and wind+wave effect times a constant.
'The table gives the percentage increase and the multiplier is
'the change in the constant, as speed also changes resistance. The
'result h#(n,2) is called by SPA if spinnaker is up, instead of h#(n,1).
For N=0 To 89
H#(N,2)=-1
H#(360-N,2)=-1
Next N
Restore SPINNAKER
For N=90 To 180
Read A#
H#(N,2)=H#(N,1)+H#(N,1)*A#*0.024
H#(360-N,2)=H#(N,2)
Next N
SPINNAKER:
Data 1,1,2,2,3,3,4,4,5,5
Data 6,6,7,7,8,8,9,9,10,10
Data 11,12,13,14,15,16,17,18,19,20
Data 22,24,26,28,30,32,34,36,38,40
Data 42,44,46,48,50,51,52,53,54,55
Data 56,58,60,62,64,66,68,70,72,75
Data 78,79,80,81,82,83,84,85,86,87
Data 88,87,86,85,84,83,82,81,80,79
Data 78,76,74,72,70,69,68,67,66,66,66
End Proc
Procedure COMMENCE
Shared A,B,F,HOR,OSCI,PITCH,H(),H#(),ANGW
Shared BX,SY,PX,RY,DAY
B=0
Do
For M=1 To 2
For N=0 To 9
Add HOR,OSCI : Add A,OSCI*PITCH
HR#= Extension_4_01D0(0) : BACKX=HR#/68.2 : HH=HR#/182 : WW=ANGW-HH
If WW<1 Then WW=WW+360
If Mouse Key<>0 : CONTROL : Else Add F,-Sgn(F) : End If : Add B,F*10
Cls 0 : Extension_4_01A6 0,A,B,C : Extension_4_01A6 1,A,B,C : Extension_4_0318
Extension_4_049E 1,BACKX,0,320,85 To 0,HOR
Screen Copy 2,0,0,320,66 To 0,0,139
Screen Copy 3,0,0,45,9 To 0,94,143
Screen Copy 3,HH,0,H(HH,2),9 To 0,94,143
Locate 27,19 : Print "Set heading,"
Locate 27,20 : Print "Press space."
Locate 14,23 : Print SPIN$
Plot BX,SY,13 : Draw To H(VE,16),H(VE,17)
Plot H(WW,3),H(WW,4),7 : Draw To H(WW,5),H(WW,6)
Plot PX,RY,13 : Draw To H(180,11),H(180,12)
If DAY=1 Then DAY=0 : Proc LIGHT
Screen Swap : Wait Vbl
Next N
OSCI=-OSCI
Next M
'stop playing
If Key State(16) Then End
Sam Play 1,1,3000 : Sam Play 2,1,4000
If Key State(64) Then HOR=-12 : OSCI=1 : A=0 : Exit
Loop
End Proc
Procedure DARK
Shared CLV(),DAY
For N=0 To 15 : CLV(N)=Colour(N) : Next N : DAY=1
Do
For N=0 To 15
If Colour(N)=0 Then COUNT=COUNT+1
If COUNT=16 Then COUNT=0 : Pop Proc
CL=Colour(N)
RED=256
If CL<256 Then RED=16
If RED=16 and CL<16 Then RED=1
CL=CL-RED
If CL<0 Then CL=0
Colour(N),CL
For P=1 To 40 : Next P
Next N
COUNT=0
Loop
End Proc
Procedure LIGHT
Shared CLV()
For N=0 To 15
Colour(N),CLV(N)
For P=1 To 400 : Next P
Next N
End Proc