MonTENzuma - alias MON10ZUMA

Category: PUR80
Computer: Amstrad CPC464 
Basic: Locomotive Basic 1.1
Emulator: WinAPE 2.0 Beta 2
Author: Francesco Fiorentini (Italy)

Instructions to load the game:
- run WinAPE 2.0 Beta 2
- File -> Disc A: -> Insert Disc Image
- Select the file MON10ZUMA.DSK
- digit the command: cat (to see the content of the disk)
- digit the command: load "MN10ZUMA.BAS" (to load the file MN10ZUMA.BAS)
- digit the command: run (to execute the game)

Game instructions: 
- collect the key to pass to next level
- avoid the snakes
- move the main character with the arrow keys

Code:
1SYMBOL 254,6,249,166:SYMBOL 255,96,240,104,8,16,32,16,8:MODE 2:D=0:K=0:X=9:Y=9
2CLS:LOCATE 10,1:? "MONTENZUMA - "CHR$(254);" ";K:LOCATE X,Y:? CHR$(249):K=K+1
3KX=INT(RND(1)*75+3):KY=INT(RND(1)*22+2):LOCATE KX,KY:? CHR$(254):? CHR$(7)
4OX=X:OY=Y:X=X+(INKEY(8)>-1)-(INKEY(1)>-1):Y=Y+(INKEY(0)>-1)-(INKEY(2)>-1)
5A=INT(RND(1)*75+3):B=INT(RND(1)*22+2):IF X<2 THEN X=2 ELSE IF X>79 THEN X=79
6LOCATE A,B:? CHR$(255):IF Y<2 THEN Y=2 ELSE IF Y>24 THEN Y=24
7LOCATE X,Y:R$=COPYCHR$(#0):IF ASC(R$)>=254 THEN GOTO 10
8LOCATE X,Y:? CHR$(249):IF X<>OX OR Y<>OY THEN LOCATE OX,OY:? " "
9GOTO 4:IF A=KX AND B=KY THEN LOCATE A,B: ? CHR$(254)
10IF R$=CHR$(254) THEN GOTO 2 ELSE ? "KILLED BY A SNAKE!":SOUND 1,300,100,15

Code Explanation:
row 1: redefines key and snakes chars; sets the video mode to 80 columns (MODE 2) and initializes variables
row 2: clears the screen and writes the first row (title and number of collected keys)
row 3: manages appearance of the key (randomly) and generates a sound CHR$(7)
row 4: stores the previous position of the main character (var. OX & OY) and manages his movement with the arrow keys
row 5: stores the random position of the snakes (var. A & B) and limit the horizontal movement of the main character
row 6: displays the snake in the screen (using var. A & B) and limit the vertical movement of the main character
row 7: manages collisions (using COPYCHR$()); if collides with a snake jump to line 10
row 8: displays the main character (pos. X & Y) and clears its previous position (var. OX & OY)
row 9: repeats the cycle from row 4 and checks that the key has not been covered by a snake
row 10: ends the game with the message KILLEDBY A SNAKE! and generates a brief sound

Additional information:
Once the game has terminated it needs to be restarted again with a RUN command.