home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 3
/
Merciful_Release_3.bin
/
software
/
s
/
skeetshoot.dms
/
skeetshoot.adf
/
skeet_shooting.amos
/
skeet_shooting.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1978-10-14
|
12KB
|
308 lines
'*****************************************************************************
'* *
'* SKEET AND TARGET SHOOTING BY STEVE BENNETT. WRITTEN IN JANUARY 91 *
'* *
'*****************************************************************************
'* This is a simple shooting game that I have done to show beginners to AMOS *
'* basic the sort of thing that can be produced in a few hundred lines of *
'* code. I have tried to make the code as easy to understand as possible by *
'* making the routines as long and as simple as I can. Certain areas may not *
'* be that easy to understand at first, but as you learn, all will become *
'* clear. I have left the program unfinished to allow you to add whatever *
'* you want. High score table. Better graphics. More sections. Etc. *
'* As a bit of advice, you should go through the program with - FOLLOW -. *
'* This will allow you to step through the program and see, to some extent *
'* what each line does. *
'* *
'* Ok game play. On the skeet shooting section you are given 20 shots. *
'* Skeets are fired at random 1, or 2 at once. The left mouse button fires *
'* the left barrel. The right mouse button fires the right barrel. You may *
'* fire 1 or both barrels if one skeet is fired, but you must fire both *
'* barrels if two skeets are fired. The gun will then reload. After the *
'* skeet section we go onto the target shooting. Again you are given 20 *
'* shots. You must fire BOTH barrels at each target. A large target in the *
'* right hand corner will display where it was hit or missed. As you shoot *
'* the gun will kick up as a real one would. You are not allowed to move the *
'* sights from the bottom of the screen until a skeet or target have been *
'* fired/setup. *
'* *
'* As I said. You may alter the program how you wish, and pass on copies *
'* to your friends. But please do not pirate my bobtoolbox program. I have *
'* put a lot of work into it, for your benefit and will be upgrading it *
'* during the year. *
'* Many Thanks. Steve Bennett. *
'* *
'* PLEASE CONTINUE TO SUPPORT THE AMOS PD LIBRARY AND JOIN THE USER GROUP *
'* *
'* Oh! must say hi to my good buddy gaz shilvock who has been mentioned *
'* in aprils amiga format for his mandelbrot generator. Its available from *
'* sandra/pd library. What it is to be famous eh!. *
'*****************************************************************************
'
'Follow :rem *** USE THIS LINE TO FOLLOW THE PROGRAM THROUGH ***
Unpack 10 To 0 : Rem *** get the background picture from bank 10 ***
Double Buffer : Rem *** used to stop bobs flickering on the screen ***
Get Sprite Palette : Rem ** use the colurs of the sprites for the screen ***
Paper 0 : Pen 1 : Rem *** set the background colour to black. front to white ***
Change Mouse 2 : Rem *** change the mouse to a crosshair ***
Limit Mouse 143,58 To 435,273 : Rem *** stop the mouse going off the screen ***
X Mouse=289 : Y Mouse=273 : Rem *** position the mouse 289 across - 273 down ***
'********* set amal channel to control - gun to mouse movement *****************
GUN$="AUtest(If R0<>XM Jump Update"
GUN$=GUN$+"If R1<>YM Jump Update else eXit"
GUN$=GUN$+"Update: Let R0=XM-158 ; Let R1=YM+27 ; Direct M)"
GUN$=GUN$+"M: If YM>204 Jump Out else Jump N ; Out: Let X=R0 ; Let Y=230"
GUN$=GUN$+"N: If YM<127 Jump S else Jump R ; S: Let X=R0 ; Let Y=151"
GUN$=GUN$+"R: Let R2=YM>127 ; Let R3=YM<204 ; If R2&R3 Jump Q else Wait ; Q: Let X=R0 ; Let Y=R1 ; Wait "
Channel 1 To Bob 1
Bob 1,131,230,1 : Rem *** position bob 1 on screen as a gun - image 1 ***
Amal 1,GUN$
Amal On 1
Channel 3 To Bob 3
'************ set animation for skeets and movement ***********
SKEET1$="A 1,(7,10)(8,10)(9,10)(10,10)(11,5)(12,5) ; PL Z(5)+1 ; M 100,50,50 ; End"
Channel 4 To Bob 4
SKEET2$="A 1,(7,10)(8,10)(9,10)(10,10)(11,5)(12,5) ; PL Z(5)+7 ; M -100,50,50 ; End"
TARGET$="Let A=15 ; Let Y=165 ; M 0,-15,30 ; For R0=0 To 50 ; Next R0 ; M 0,15,30 ; End"
'
SKEETS=0 : Rem *** number of skeets fired ***
SHOTS=0 : Rem *** number of shots fired ***
HITS=0 : Rem *** how many hits ***
MISSES=0 : Rem *** how many misses ***
SCORE=0 : Rem *** what your score ***
DESTROYED=0 : Rem *** how many skeets destroyed ***
LEVEL=1 : Rem *** start at level 1 - skeet shooting ***
Screen Open 1,640,16,4,Hires : Rem *** open info screen for score etc. ***
Screen Display 1,,42,,8 : Rem *** position info screen at top of display ***
Paper 1 : Pen 2
Print " SKEETS ";SKEETS; : Print " SHOTS ";SHOTS; : Print " HITS ";HITS; : Print " MISSES ";MISSES; : Print " SCORE ";SCORE
Screen 0 : Rem *** set screen to work in ***
Auto View On : Rem *** allow screen changes to be seen ***
LEFTBARREL=1 : RIGHTBARREL=1 : Rem *** left/right barrel loaded ***
'
'************* main skeet shooting routine *********************
Repeat
'
If(Chanmv(3)=0) and(Chanmv(4)=0) Then Gosub SKEETFIRE
'
If Y Mouse>204 Then Colour 2,$FFF : Else Colour 2,$F
'
KEY=Mouse Key
'
If(KEY=1) and(LEFTBARREL=1) : Rem *** if button pressed and left barrel full ***
Bob 2,X Mouse-138,Y Mouse-52,18 : Rem *** put bullet on screen ***
Y Mouse=Y Mouse-10 : Rem *** make mouse jump ***
Sam Play 1,2 : Rem *** make shot sound ***
For T=3 To 4 : Rem *** check if skeet hit. If so add 10 to score ***
If Bob Col(T,2 To 2) : Bob T,X Bob(T)-5,Y Bob(T)-5,13 : Amal Off T
Add SCORE,10
Wait 2 : Bob Off 2 : Wait 10 : Bob Off T : HIT=1
End If : Next T
LEFTBARREL=0 : Rem *** left barrel empty ***
Inc SHOTS : Rem *** add 1 to number of shots fired ***
If HIT=1 : Rem ***if skeet hit add 1 to hits and 1 to number destroyed ***
Inc HITS : HIT=0 : Inc DESTROYED
Else Inc MISSES : Rem *** if not hit add 1 to number of misses ***
End If
Wait 2 : Rem *** wait 2 vertical blanks to slow the program down ***
Bob Off 2 : Rem *** turn off bullet bob ***
End If
'
'********* now do the same tests for the right barrel *****************
If(KEY=2) and(RIGHTBARREL=1)
Bob 2,X Mouse-138,Y Mouse-52,18
Sam Play 2,2
Y Mouse=Y Mouse-10
For T=3 To 4
If Bob Col(T,2 To 2) : Bob T,X Bob(T)-5,Y Bob(T)-5,13 : Amal Off T
Add SCORE,10
Wait 2 : Bob Off 2 : Wait 10 : Bob Off T : HIT=1
End If : Next T
RIGHTBARREL=0
Inc SHOTS
If HIT=1
Inc HITS : HIT=0 : Inc DESTROYED
Else Inc MISSES
End If
Wait 2
Bob Off 2
End If
'
If(LEFTBARREL=0) and(RIGHTBARREL=0) : Rem *** if both barrels empty ****
If(DESTROYED=2) and(WHICHHUT=3) : Add SCORE,100 : Sam Play 3,1
Screen 1 : Print " BONUS 100 POINTS"
Wait 50 : Screen 0
End If : Rem *** if both skeets hit. cheer sound. add 100 to score. ***
Wait 20
Gosub RELOAD : Rem *** goto reload routine at the bottom of the program ***
LEFTBARREL=1 : RIGHTBARREL=1 : Rem *** reloaded both barrels ******
End If
'
'********** if skeets stopped moving turn them off **********
If Chanmv(3)=0 Then Bob Off 3 : Amal Off 3
If Chanmv(4)=0 Then Bob Off 4 : Amal Off 4
'
Until SHOTS=20 : Rem *** repeat until 20 shots fired *******
'
'
'**** Ok! There should be enough information in the REMS above to give ***
'**** you some idea of how the section works. Now try to follow the
'**** next section, target shooting and try to see how it works.
'**** Don't try to rush. AMOS take a while to learn, even the simply
'**** routines take time to get right. The best of luck.
'
'
LEVEL2: Rem ************** target shooting **************
LEVEL=2 : SHOTS=0
Get Sprite Palette
Bob 9,230,20,17
Bob 3,100,165,15 : Limit Bob 3,0,0 To 320,163
LEFTBARREL=1 : RIGHTBARREL=1
Screen 1
Cls
Locate 29,0 : Print "SHOTS ";SHOTS; : Locate 47,0 : Print "SCORE ";SCORE
Screen 0
Wait 200
WHERETARGET=Rnd(185)+80
Bob 3,WHERETARGET,165,15 : Limit Bob 3,0,0 To 320,163 : Amal 3,TARGET$
Amal On 3 : Wait Vbl
Do
'
MIDDLEX=X Bob(3)+135 : MIDDLEY=198
MOUSEX=X Mouse : MOUSE=Y Mouse
XAIM=240+((X Mouse-MIDDLEX)*6)
YAIM=((Y Mouse-MIDDLEY)*7)+Y Mouse
KEY=Mouse Key
'
If(KEY=1) and(LEFTBARREL=1)
Bob 10,XAIM+26,YAIM-143,16
Sam Play 1,2
Y Mouse=Y Mouse-10
LEFTBARREL=0
Inc SHOTS
CHECKSCORE=Point(X Bob(10),Y Bob(10))
If CHECKSCORE=2 : Add SCORE,100 : Wait 10 : Sam Play 3,1 : End If
If CHECKSCORE=11 : Add SCORE,50 : End If
If CHECKSCORE=31 : Add SCORE,20 : End If
End If
'
If(KEY=2) and(RIGHTBARREL=1)
Bob 11,XAIM+26,YAIM-143,16
Sam Play 2,2
Y Mouse=Y Mouse-10
RIGHTBARREL=0
Inc SHOTS
If X Bob(10)=X Bob(11) : Bob 11,X Bob(10)+5,, : End If
CHECKSCORE=Point(X Bob(11),Y Bob(11))
If CHECKSCORE=2 : Add SCORE,100 : Wait 10 : Sam Play 3,1 : End If
If CHECKSCORE=11 : Add SCORE,50 : End If
If CHECKSCORE=31 : Add SCORE,20 : End If
End If
'
'
If SHOTS=20 Then End : Rem *** Its over, its over, its ooooovvver ***
If(LEFTBARREL=0) and(RIGHTBARREL=0)
Wait 20
Y Mouse=Y Mouse+20
' Paste Bob 230,20,17
Gosub RELOAD
' Bob Off 9 : Bob Off 10 : Bob Off 11
LEFTBARREL=1 : RIGHTBARREL=1
WHERETARGET=Rnd(185)+80
Bob 3,WHERETARGET,165,15 : Limit Bob 3,0,0 To 320,163 : Amal 3,TARGET$
Amal On 3 : Wait Vbl
End If
Loop : Rem **************** end of target shooting ***********
'
SKEETFIRE:
'
CLOCK=Rnd(100)+1 : Wait CLOCK
'
WHICHHUT=Rnd(2)+1
'
If(WHICHHUT=1) and(Chanmv(3)<>-1)
Bob 3,30,225,7 : Amal 3,SKEET1$ : Amal On 3
Limit Bob 3,0,0 To 320,220
Inc SKEETS
End If
'
If(WHICHHUT=2) and(Chanmv(4)<>-1)
Bob 4,280,225,7 : Amal 4,SKEET2$ : Amal On 4
Limit Bob 4,0,0 To 320,220
Inc SKEETS
End If
'
If(WHICHHUT=3) and(LEFTBARREL=1) and(RIGHTBARREL=1)
If(Chanmv(3)<>-1) and(Chanmv(4)<>-1)
Bob 3,30,225,7 : Amal 3,SKEET1$
Limit Bob 3,0,0 To 320,220
Bob 4,280,225,7 : Amal 4,SKEET2$
Limit Bob 4,0,0 To 320,220
Add SKEETS,2 : Amal On 3 : Amal On 4
End If : End If
'
Screen 1
Print " SKEETS ";SKEETS; : Print " SHOTS ";SHOTS; : Print " HITS ";HITS; : Print " MISSES ";MISSES; : Print " SCORE ";SCORE
Screen 0
'
Y Mouse=273
Return
'
'****** This section reloads the gun. That could be why I called it reload ***
RELOAD:
Wait 50
Bob Off 9 : Bob Off 10 : Bob Off 11
Amal Freeze 1
Repeat : Until(Chanmv(3)=0) and(Chanmv(4)=0)
Bob Off 3 : Bob Off 4 : Hide
If LEVEL=1
Screen 1
Print " SKEETS ";SKEETS; : Print " SHOTS ";SHOTS; : Print " HITS ";HITS; : Print " MISSES ";MISSES; : Print " SCORE ";SCORE
Screen 0
End If
If(LEVEL=2) or(LEVEL=3)
Screen 1
Locate 29,0 : Print "SHOTS ";SHOTS; : Locate 47,0 : Print "SCORE ";SCORE
Screen 0
End If
For T=Y Bob(1) To 260
Bob 1,,T,
Wait Vbl
Next T
For T=260 To 190 Step -1
Bob 1,130,T,3
Bob 2,127,Y Bob(1)+4,4
Wait Vbl
Next T
For T=4 To 6
Bob 2,,194,T
Wait 2
Next T
Bob 2,,260,4
Wait 50
For T=6 To 4 Step -1
Bob 2,,194,T
Wait Vbl
Next T
Bob 2,,194,4
For T=190 To 260
Bob 1,,T,
Bob 2,,T+4,
Wait Vbl
Next T
Wait 50
For T=260 To 230 Step -1
Bob 1,131,T,1
Bob Off 2
Wait Vbl
Next T
X Mouse=289 : Y Mouse=273
Wait Vbl
DESTROYED=0
Show On
Amal On 1
If LEVEL=2 Then Get Sprite Palette : Bob 9,230,20,17
Wait 50
Return
'
'************** That's the end of the road folks *******************************