home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
476-500
/
apd496
/
commented-yachting.amos
/
commented-yachting.amosSourceCode
Wrap
AMOS Source Code
|
1986-08-03
|
14KB
|
501 lines
'
' *******************************************
' * *
' * Yachting 1993 *
' * -------- *
' * THIS IS THE OLD VERSION *
' * written by Stephan Scholz *
' * *
' * A yachting simulator on a lake with *
' * three buoys, one competitor yacht *
' * and a Vista generated background. *
' * *
' * 12 Knot Wind. - Beaufort Force 3 *
' * *
' * Click mouse on < > ^ v symbols *
' * round the dashboard instruments. *
' * to turn rudder left or right, to *
' * bring in or let out sailboom, and *
' * on the little box for spinnaker. *
' * *
' *******************************************
'
Set Buffer 40
Dim H(360,15)
Dim H#(360,2)
Dim BUOY(3,3)
Proc COMMENCE
Proc SAILDATA
Proc SCRNOBJLDR
Proc SETTINGS
Do
For HO=1 To 10
'horizon oscillation
Add HOR,OSCI
Add A,OSCI*PITCH
'get your heading
HR#= Extension_4_01D0(0)
'background view or orientation angle
BACKX=HR#/68.2
'heading
HH=HR#/182
'relative wind
WW=ANGW-HH
If WW<1 Then WW=WW+360
'windward side right(+) or left(-)
TK=Sgn(WW-180)
'boom angle
SIL=180-(SAIL*TK)
'boom angle when loose in the wind
TI=180*TK
QWW=180-WW
VES=VE#*VE#
'force of apparent wind (FAPWIND is square of windspeed)
FAPWIND=(SWIND)+(VES)-2*(WIND*VE#*Cos(QWW))
'APWIND# is apparent windspeed or force
APWIND#=Sqr(FAPWIND)
'AWA is apparent wind direction
AWA=WW-(90-Acos((VE#*Sin(QWW))/APWIND#))
'boom angle when loose in wind (180 degrees less)
AWT=AWA-TI
'sail angle of incidence
INS=(AWT-SIL)*-TK
If INS<1
SIL=AWT
INS=1
End If
'boom colours
FAR=H(INS,15)
'sail efficiency as per angle tables
FSAIL=H(INS,14)*Abs(Sin(SIL))
'total propulsion * square of windspeed and working
'coefficient which accounts for water resistence and
'wave factor when reaching or running free, and spinnaker if up.
PROP#=FSAIL*FAPWIND*H#(WW,SPA)
'speed increase or decrease as per propulsion difference
VE#=VE#-(Sgn(VE#-PROP#)*0.025)
'the following line should be VE=VE#*20 if using a 68030 and in the
'SAILDATA procedure a change is also indicated before the AUTOS data.
VE=VE#*40
If Mouse Key<>0
CONTROL
Else
'self correcting rudder
Add F,-Sgn(F)
End If
G=F*VE/4
F1=F*2
RUD=180
Add G,F1
Add RUD,-F1
'alter heading as per rudder
Add B,G
Extension_4_01A6 0,A,B,C
Extension_4_0100 0,VE
'movement of competitor as per its wind angle table established
'every finished for next loop, depending on its orientation.
Add VE1,Sgn(H(WW1,13)-VE1)
Extension_4_01A6 1,A,B1,C
Extension_4_0100 1,VE1
Cls 0
Extension_4_0318
'background scroll
Extension_4_049E 1,BACKX,0,960,85 To 0,HOR
'draw dashboard
Screen Copy 2,0,0,320,66 To 0,0,139
'
'instrument pointers and numbers
'
Locate 27,19
'your speed:
Print VE#
'print spinnaker indicator:
Locate 14,21
Print SPIN$
'compass bearing:
Locate 12,19
COMPAS=H(HH,1)
Print Mid$(COMPAS$,COMPAS,5)
'apparent wind:
Plot H(AWA,3),H(AWA,4),7
Draw To H(AWA,5),H(AWA,6)
'use the following line to see the real wind:
'Draw H(WW,3),H(WW,4) To H(WW,5),H(WW,6)
'sail boom:
Plot PX,PY,FAR
Draw To H(SIL,7),H(SIL,8)
'rudder:
Plot PX,RY,13
Draw To H(RUD,11),H(RUD,12)
'competitor's position on scanner:
Plot 59+LX1/3125,170-LZ1/3125,7
'your position on scanner:
Plot 59+LX/3125,170-LZ/3125,13
Screen Swap
Wait Vbl
Next HO
If VE#<0 Then VE#=0
'update your position
LX= Extension_4_0114(0)
LZ= Extension_4_013C(0)
'keep your ship on map
If Abs(LZ)>90000 Then LZ=90000*Sgn(LZ)
If Abs(LX)>90000 Then LX=90000*Sgn(LX)
'a minor correction for totally rear wind
If AWA=180 Then Add F,5
'a minor correction to avoid boat taking off (ly=0)
Extension_4_00EC 0,LX,LY,LZ
'collision detection
If Extension_4_0344(0)>0 Then CRASH
'invert horizon oscillation
OSCI=-OSCI
SHIPS
ROBWIND
Loop
Procedure CRASH
Shared LX,LY,LZ,LX1,LY1,LZ1,CHOCA,F,HR#,VE#,CRA,HH,HH1,CRA
Boom
'bumps counter
Inc CHOCA
N= Extension_4_0344(0)
'checks which side of your ship collision has occured on
CRA= Extension_4_0258(0,N)-HR#
'brusque rudder movement away from other ship
F=40*-Sgn(CRA)
End Proc
Procedure SHIPS
Shared LX1,LX,LZ1,LZ,LY,LY1,B,B1,WW1,HH1,TK1,ANGW
Shared X5,Y5,Z5,X6,Y6,Z6,BO1,BO0,BUOY(),BCOUNT,B1COUNT,CHOCA,SPAU
LX1= Extension_4_0114(1)
LZ1= Extension_4_013C(1)
'keep ship on map
If Abs(LZ1)>90000 Then LZ1=90000*Sgn(LZ1)
If Abs(LX1)>90000 Then LX1=90000*Sgn(LX1)
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)
'if against wind try again
If WW1<40
B1=B1+((Rnd(15)+40)-WW1*TK1)
Goto MIRA
End If
'if near enough buoy head for next one (competitor)
If Extension_4_028E(1,X5,Y5,Z5)<2000
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 near enough, record this buoy and set next one (your ship)
If Extension_4_028E(0,X6,Y6,Z6)<3000
Bell
Inc BCOUNT
If BO0<3
Inc BO0
X6=BUOY(BO0,1)
Y6=BUOY(BO0,2)
Z6=BUOY(BO0,3)
End If
End If
'if you've arrived at last buoy...
If BCOUNT=3
Locate 27,19
Print "Bumps:";CHOCA
Locate 27,20
If B1COUNT<3
Print "You've won"
End If
Screen Swap
Wait 200
Bell
Locate 27,19
Print "Turn north,"
Locate 27,20
Print "race again."
Screen Swap
Wait 200
Bell
BCOUNT=0
B1COUNT=0
CHOCA=0
SETTINGS
End If
End Proc
Procedure ROBWIND
Shared ANGW,VE#,VE1,SV0,SV1,DSE
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)<20
Shoot
If VE#>0.5
VE#=VE#-0.5
Pop Proc
End If
End If
Add SV1,-ANGW
If Abs(SV1)<20
Bell
If VE1>20
Add VE1,-20
Pop Proc
End If
End If
End If
End Proc
Procedure CONTROL
Shared FOCK,SAIL,F,FM,SPA,SPIN$
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 : Pop Proc : End If
Else
If SAIL>0 : Dec SAIL : Pop Proc : End If
End If
End If
If X<32
Bell
If SPIN$="v" : SPA=2 : SPIN$="^" : Wait 2 : Pop Proc
Else
SPIN$="v" : SPA=1 : Wait 2 : Pop Proc : End If
End If
End Proc
Procedure COMMENCE
Shared WIND,SWIND,SAIL,ANGW,OSCI,HOR,PITCH
Extension_4_0548 : Degree : Curs Off
Paper 0 : Ink 0,9 : Cls 0 : Pen 4
Locate 0,6
Print " La Oroya presents:"
Print
Print " * * * REGATTA * * *"
Print
Print " Greetings to Mad Max and Kid Blast"
Print : Print : Print : Print
Randomize Timer
WIND=12
SWIND=WIND*WIND
AGAIN:
ANGW=Rnd(359)
'this avoids head-wind at start
If Abs(ANGW)<45 Then Goto AGAIN
If ANGW=180 or ANGW=0 Then ANGW=ANGW+1
Print " Wind direction:";ANGW;" deg. N"
Print
Print " Wind speed :";WIND;" Kts."
'Horizon oscillation
OSCI=1
HOR=-12
'and its relationship to ship�s pitching
PITCH=72
End Proc
Procedure SETTINGS
Shared LX,LX1,LY,LY1,LZ,LZ1,BUOY(),BO0,BO1
Shared X5,Y5,Z5,X6,Z6,Y6,SAIL,FOCK,FM,SPA,SPIN$
LX=62000
LY=200
LX1=64000
LY1=500
LZ=-70000
LZ1=-65000
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
H=-100
BUOY(1,1)=0 : BUOY(1,2)=H : BUOY(1,3)=53000
BUOY(2,1)=-53000 : BUOY(2,2)=H : BUOY(2,3)=-53000
BUOY(3,1)=53000 : BUOY(3,2)=H : BUOY(3,3)=-53000
'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=30
FOCK=30
'maximum rudder angle
FM=12
'spinnaker stowed at start
SPIN$="v"
SPA=1
Pen 3
End Proc
Procedure SCRNOBJLDR
'background landscape loading and preparation of extra long strip.
Screen Open 0,320,256,16,Lowres : Flash Off : Curs Off
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
Get Palette 0
Screen Display 0,,,320,205
'dashboard loading and copying to a storage screen
Load Iff "Yachting:IFFs/Dashboard.IFF"
Screen Open 2,320,66,16,Lowres : Flash Off : Curs Off
Screen Copy 0,0,139,320,256 To 2,0,0
Get Palette 0
Screen Hide 2 : 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"
Extension_4_0036 1,"yacht",65000,0,-55000,0,0,0
Extension_4_0036 2,"buoy1",0,H,50000,0,0,0
Extension_4_0036 3,"buoy2",-50000,0,-50000,0,0,0
Extension_4_0036 4,"buoy3",50000,0,-50000,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,NAN#,NIN#,NON#,H(),H#(),COMPAS$,WIND,SWIND
COMPAS$=" -N- n.e -E- s.e -S- s.w -W- n.w -N- "
'points on screen for navigation instruments:
PX=176
PY=171
BY=155
RY=189
NAN#=15
NIN#=17
NON#=19
For N=0 To 360
SN#=Sin(N)
CN#=-Cos(N)
'compass instrument data:
H(N,1)=2+N/9
H(N,2)=0
'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#
'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#
'the following should be h(n,13)=a#*1.4 if using a 68030
H(N,13)=A#*2.8
Next N
AUTOS:
Data 0,0,0,0,5,10,15,20,25,30
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