Rem ************************************ Rem * AMOS Example 13.6 * Rem * Bob and Sprite collisions * Rem * (c) Mandarin / Jawx 1990 * Rem ************************************ Rem Rem Initalisation Double Buffer Rem Make some images MAKE_OBJECTS Curs Off : Cls 0 Rem Assign bob 1 to amal channel 1 Channel 1 To Bob 1 Bob 1,0,0,3 Rem Define attack wave A$="Loop: Let RH=180 Let RW=300" A$=A$+" For RL=0 To 5" A$=A$+" Let RH=RH-16 Let RW=RW-16 " A$=A$+" For R0=1 To RW/4 Let X=X+4 Next R0" A$=A$+" For R0=1 To RH/4 Let Y=Y+4 Next R0" A$=A$+" Let RH=RH-16 Let RW=RW-16" A$=A$+" For R0=1 To RW/4 Let X=X-4 Next R0" A$=A$+" For R0=1 To RH/4 Let Y=Y-4 Next R0" A$=A$+" Next RL" A$=A$+" For RL=0 To 5" A$=A$+" For R0=1 To RW/4 Let X=X+4 Next R0" A$=A$+" For R0=1 To RH/4 Let Y=Y+4 Next R0" A$=A$+" Let RH=RH+16 Let RW=RW+16" A$=A$+" For R0=1 To RW/4 Let X=X-4 Next R0" A$=A$+" For R0=1 To RH/4 Let Y=Y-4 Next R0" A$=A$+" Let RH=RH+16 Let RW=RW+16 " A$=A$+" Next RL: Jump Loop" Rem Load attack wave into channel 1 Amal 1,A$ Rem Make collision detection mask Make Mask Rem Start attack Amal On Rem---------------------------------------- Rem Call mouse control routine MOUSE_CONTROL Rem Exit Sprite Off : Bob Off Rem--------------------------------------- End Procedure MOUSE_CONTROL Rem This procedure controls the ship and detects a collision Hide On IMAGE=1 : Rem choose bob image Rem Main loop Repeat Rem position ship at mouse coords Sprite 8,X Mouse,220,IMAGE : Wait Vbl Rem fire missile If Mouse Click Then MISSILE Rem check for collisions If Bobsprite Col(1) Rem did alien hit ship If Col(8) : Boom : Locate 0,0 : Centre "" : DEAD=True : End If Rem did missile hit ship If Col(9) : Boom : Amal Off Locate 0,0 : Centre "" : DEAD=True End If End If Until DEAD End Proc Procedure MISSILE Rem fire missile Sprite 9,X Mouse,215,2 A$="Move 0,-200,25" Amal 9,A$ Amal On Shoot End Proc Procedure MAKE_OBJECTS Rem Generate the images required for the game on the fly Cls 0 Rem Get generate ship Polygon 8,0 To 16,16 To 0,16 To 8,0 Ink 0 Polygon 8,10 To 16,16 To 0,16 To 8,10 Get Sprite 1,0,0 To 16,16 Rem Hot spot at centre of ship Hot Spot 1,$11 Rem Create missile Cls 0,0,0 To 17,17 Ink 2 Bar 7,0 To 9,16 Get Sprite 2,0,0 To 16,16 Rem Hot spot at tip of missile Hot Spot 2,$10 Rem Draw alien Cls 0,0,0 To 17,17 Ink 3 Polygon 16,0 To 32,8 To 20,16 To 12,16 To 0,8 To 16,0 Get Bob 3,0,0 To 32,17 Bob 1,100,100,3 End Proc