Rem *************************************** Rem * AMOS Example 13.3 * Rem * Controlling a bob with the joystick * Rem * (c) Mandarin / Jawx 1990 * Rem *************************************** Rem Rem Initalisation Curs Off : Cls 0 Load "AMOS_DATA:Sprites/Octopus.abk" Double Buffer : Flash Off : Get Sprite Palette Rem Dimension X,Y offset arrays Dim DX(16),DY(16) Rem Load offset arrays INIT=True : CONTROL_BOB[INIT] Rem Call bob control routine CONTROL_BOB[0] End Procedure CONTROL_BOB[INIT] Rem Initalize object Shared DX(),DY() If INIT Rem SPEED holds the size of each movement step SPEED=2 : Rem Reasonable values range from 1(slow) to 5(veryfast) Rem Load offset arrays used to change coordinates of bob For I=1 To 15 : Read X,Y : DX(I)=X*SPEED : DY(I)=Y*SPEED : Next I Else Rem Control a bob Rem Works equally well for sprites X1=160 : Y1=100 : Rem sets the starting position of object IMAGE=1 : Rem Sets image used by object Do Bob 1,X1,Y1,IMAGE : Rem move bob Rem Read joystick and get new coordinates J=Joy(1) and 15 : Add X1,DX(J),10 To 300 : Add Y1,DY(J),10 To 190 Exit If Joy(1)>15 : Rem test fire buttton Loop End If Rem offset data Data 0,-1,0,1,0,0,-1,0,-1,-1,-1,1 Data 0,0,1,0,1,-1,1,1,0,0,0,0,0,0,0,0,0,0,0 End Proc