home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
games
/
gundemo.amos
/
gundemo.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1991-10-08
|
6KB
|
281 lines
' initialise some variables used in the game
Screen Open 0,320,256,16,Lowres
Print "LOADING"
XCAL=0 : YCAL=0
MX=0 : MY=0 : MSHOT=0
MXPTR=Varptr(MX)
MYPTR=Varptr(MY)
MSHOTPTR=Varptr(MSHOT)
OLDSHOT=0
' Initialise Gun and screen
Dreg(0)=0
Call 6
Dir$="df0:amos/"
Load "demo.abk",1
Hide : Curs Off : Cls 0 : Flash Off : Get Sprite Palette
Proc CALIBRATEGUN
Proc GAMEPLAY
'
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'
' Main game procedure controls everything
Procedure GAMEPLAY
Shared MSHOT,MX,MY,QUALIFY,ROUND,FAIL,SCORE,HISCORE,HITS,SHOTS
QUALIFY=10 : ROUND=1 : FAIL=0
SCORE=0 : HISCORE=2000
Repeat
Proc FRONTEND
Proc SETUP_SCREEN
Proc ROUNDPLAY
QUALIFY=QUALIFY+3
ROUND=ROUND+1
HITS=0 : SHOTS=0
Until FAIL=-1
End Proc
'
'
' Set up screen for correct round number
Procedure FRONTEND
Shared QUALIFY,ROUND
Get Sprite Palette
Cls 0
Pen 5
Locate 15,3 : Print "Round ";ROUND
Locate 0,6 : Print "You need to get targets in 15 seconds"
Locate 7,9 : Print "Pull trigger to play demo"
Pen 15 : Locate 15,6 : Print QUALIFY
Pen 6
Wait 20
Proc TRIGWAIT : Rem waits till trigger is pulled
Locate 14,12 : Print "Get Ready"
End Proc
'
Procedure SETUP_SCREEN
Shared HISCORE,SCORE
Load Iff "Backdrop.iff",0
Colour 1,$F00
Ink 0 : Gr Writing 0
Text 76,11,"HITS"
Text 133,11,"SCORE"
Text 197,11,"HI-SCORE"
Text 281,11,"TIME"
Text 213,20,Str$(HISCORE)
Ink 15
Text 75,10,"HITS"
Text 132,10,"SCORE"
Text 196,10,"HI-SCORE"
Text 280,10,"TIME"
Text 212,19,Str$(HISCORE)
Gr Writing 0
Proc SCOREUPDATE
Hide
Double Buffer
Autoback 1
End Proc
'
' Play one round for one player
Procedure ROUNDPLAY
Shared MSHOT,MX,MY,FAIL,SCORE,HITS
HITS=0 : SHOTS=0
Make Mask
Timer=0 : TIME=15
Paper 0 : Pen 1
Proc TIMEUPDATE[TIME]
Proc HITSUPDATE
Repeat
A=0
Proc TARGETSUP : Rem get targetsto appear
Repeat
Proc TRIGGER : Rem repeats until shot is fired
If MSHOT=-1 Then Proc SHOT[MX,MY]
Proc DETECT : Rem check for collision
If Timer>40 Then TIME=TIME-1 : Timer=0 : Proc TIMEUPDATE[TIME]
If TIME<=0 Then Goto OUT
Inc A : Rem time length of time targets have been on
Until A>160 : Rem wait for 4 seconds then start again
OUT:
Until TIME<=0
Proc STATS
End Proc
'
Procedure STATS
Shared SHOTS,HITS,FAIL,QUALIFY
Flash Off
Fade 1 : Wait 15
Amal Off : Bob Off
Wait Vbl
Screen Swap : Cls 0 : Screen Swap : Cls 0
Paper 0
Locate 13,20
If HITS<QUALIFY
Print " You failed"
FAIL=-1
Else
Print "YOU DID IT!!"
FAIL=0
End If
Paste Bob 85,35,10
Pen 9
Locate 10,9 : Print "You shot bullets"
Locate 10,12 : Print "You hit "
Locate 10,15 : Print "You needed "
Locate 10,18 : Print "That's hit rate"
HITS#=HITS : SHOTS#=SHOTS
If HITS=0 Then PERCENT#=0 Else PERCENT#=(HITS#/SHOTS#)*100
PERCENT=PERCENT#
Pen 8 : Locate 18,9 : Print SHOTS
Locate 17,12 : Print HITS
Locate 20,15 : Print QUALIFY
Locate 16,18 : Print PERCENT
Pen 4 : Locate 19,18 : Print "%"
Fade 2,0,$FFF,$FFA,$FE5,$FE0,$EB0,$C80,$B60,$BBB,$B77
Wait 10
Proc TRIGWAIT
End Proc
'
Procedure TIMEUPDATE[TIME]
Rem update time
Autoback 1
Gr Writing 1
Ink 15,0 : Text 291,20,Str$(TIME)+" "
End Proc
'
Procedure SCOREUPDATE
Shared SCORE
Rem update
Autoback 1
Gr Writing 1
Ink 15,0 : Text 138,20,Str$(SCORE)
End Proc
'
Procedure HITSUPDATE
Shared HITS
Autoback 1
Gr Writing 1
Ink 15,0 : Text 85,20,Str$(HITS)
End Proc
'
Procedure DETECT
C=Bob Col(1,2 To 5) : Rem check for kill between bob 1(shot) and bobs 2-5(targets)
If C=0 Then Pop Proc : Rem if no collision then don't continue
For G=2 To 5 : Rem but whick one is shot?
If Col(G)=-1 Then TARGET=G
Next G
Proc TARGETSHOT[TARGET]
End Proc
'
Procedure TARGETSHOT[TARGET]
Shared HITS,SCORE
If I Bob(TARGET)<>4 Then Pop Proc : Rem otherwise you can shoot explosions
Rem target hit sequence
DEAD$="Anim 1,(5,5)(6,5)(7,5)(1,1);"
Amal TARGET,DEAD$
Amal On TARGET
HITS=HITS+1
SCORE=SCORE+100
Proc HITSUPDATE
Proc SCOREUPDATE
Boom
End Proc
'
Procedure TARGETSUP
PAUSE$="Anim 1,(1,50)" : Rem pause before they appear
TURN$="(2,7)(3,7)(4,7);"
X=Rnd(200)
Y=Rnd(80)+130
For G=2 To 5
Channel G To Bob G : Bob G,X,Y,1
X=X+30
Amal G,PAUSE$+TURN$
Next G
Amal On
End Proc
'
Procedure SHOT[X,Y]
Shared SHOTS
SHOT$="A 1,(9,3)(1,1);"
Channel 1 To Bob 1 : Bob 1,X,Y,9
Shoot
SHOTS=SHOTS+1
Amal 1,SHOT$
Amal On 1
End Proc
'
'
'
' Calibrate the gun
Procedure CALIBRATEGUN
Shared MSHOT,XCAL,YCAL,MX,MY
Cls 0 : Pen 15 : Paper 0
Locate 6,5 : Print "Fire at target to calibrate"
Paste Bob 144,84,4
Bob Draw
Wait Vbl
Bob Draw
OK=False
Repeat
XCAL=0
YCAL=0
' clear trigger
MSHOT=0
' init trigger
Dreg(0)=0
Call 6
Repeat
Proc TRIGGER
Until MSHOT=-1
XCAL=160-MX
YCAL=100-MY
If XCAL<40 and XCAL>-40 Then OK=True
If YCAL<80 and YCAL>-80 Then OK=True
Until OK
Cls 0
End Proc
'
' Wait for the trigger to be pressed then return
Procedure TRIGWAIT
Shared MSHOT,MSHOTPTR
' init trigger
Dreg(0)=0
Call 6
MSHOT=0
Repeat
MSHOT=Jleft(1)
Until MSHOT=-1
End Proc
'
'
' Read the trigger and goto beampos if pressed, should be last routine called
Procedure TRIGGER
Shared MSHOT,OLDSHOT,MSHOTPTR
' read trigger - valptr in a0
MSHOT=Jleft(1)
If MSHOT<>OLDSHOT
OLDSHOT=MSHOT
If MSHOT=-1 : Proc BEAMPOS : End If
Else
Wait Vbl
MSHOT=0
End If
End Proc
'
' Return values in MX,MY,MSHOT = -1 if shot
Procedure BEAMPOS
Shared MSHOT,MX,MY,MXPTR,MYPTR,MSHOTPTR,XCAL,YCAL
Dreg(0)=2
Dreg(1)=Cop Logic
Dreg(2)=Phybase(0)
Dreg(3)=Phybase(1)
Dreg(4)=Phybase(2)
Dreg(5)=Phybase(3)
Areg(0)=MXPTR
Areg(1)=MYPTR
Areg(2)=MSHOTPTR
Call 6
MX=MX+XCAL
MY=MY+YCAL
If MY<0 or MY>255 Then MSHOT=0
End Proc
'