home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / gfx / misc / mazetest / mazetest.amos / mazetest.amosSourceCode
AMOS Source Code  |  1994-11-25  |  8KB  |  298 lines

  1. ' IFF Map reader test program
  2. ' This is part of a larger program that I am working on
  3. ' Therefore, the shape table contains a lot of items not used
  4. 'in this demo. Be sure to get the keys. You need them for the doors. 
  5. Set Buffer 10 : Rem more if needed 
  6. Dim OBJECTS(39),OBJECT$(39),FLAG(39),KEY(10)
  7. Dim D$(4),MAP(4,2),M(9),N(4)
  8. Goto INFORMATION
  9.  
  10. ' gosubs here for quick program access 
  11.  
  12. MICE1:
  13. 'Keyboard and mouse input
  14. K$="" : Clear Key 
  15. While K$=""
  16.    K$=Inkey$
  17.    If Mouse Key<>0 Then K$="1"
  18. Wend 
  19. While Mouse Key<>0 : Wend 
  20. XM=X Mouse-128 : YM=Y Mouse-50 : MC=Point(XM,YM)
  21. TEMP=0 : NS=N : Goto ENTRY1
  22.  
  23. ENTRY:
  24. Curs On : Input "Your response ";TEMP$
  25. TEMP$=Lower$(TEMP$) : Curs Off 
  26. 'goto entry1 
  27.  
  28. ENTRY1:
  29. CLOCK=CLOCK+1 : FLAG=0 : Rem loop flag
  30. 'goto cleartext
  31.  
  32. CLEARTEXT:
  33. For X1=20 To 22
  34.    Locate 0,X1 : Print "                                        "
  35. Next 
  36. Locate 0,23 : Print "                                       "
  37. Locate 0,20
  38. Return 
  39.  
  40. ANYKEY:
  41. Print "any key to continue."
  42. K$=""
  43. While K$=""
  44.    K$=Inkey$
  45.    If Mouse Key<>0 Then K$="1"
  46. Wend 
  47. While Mouse Key<>0 : Wend : Return 
  48.  
  49. MAP:
  50. ' display the game map 
  51. Screen To Front 2 : Screen 2
  52. Change Mouse 2 : 
  53. K$=""
  54. While K$=""
  55.    X Mouse=128+X : Y Mouse=50+Y : K$=Inkey$
  56.    Wait 20 : Hide : Wait 20 : Show 
  57.    If Mouse Key<>0 Then K$="1"
  58. Wend 
  59. Change Mouse 1
  60. Screen To Front 1 : Screen 1
  61. Return 
  62.  
  63. LANDSCAPES:
  64. Bob Off : Wait Vbl 
  65. 'read map
  66. Screen 2
  67. If N=1
  68.    For YY=0 To 4 : For XX=0 To 2
  69.       MAP(YY,XX)=Point(X+XX-1,Y+YY-4)
  70.    Next : Next 
  71. Else If N=2
  72.    For YY=0 To 4 : For XX=0 To 2
  73.       MAP(YY,XX)=Point(X-YY+4,Y+XX-1)
  74.    Next : Next 
  75. Else If N=3
  76.    For YY=0 To 4 : For XX=0 To 2
  77.       MAP(YY,XX)=Point(X-XX+1,Y-YY+4)
  78.    Next : Next 
  79. Else If N=4
  80.    For YY=0 To 4 : For XX=0 To 2
  81.       MAP(YY,XX)=Point(X+YY-4,Y-XX+1)
  82.    Next : Next 
  83. End If 
  84. Plot X,Y,7
  85. ROOM=X*Y
  86. If MAP(4,1)=2 Then FLAG(19)=ROOM
  87. 'Generate 3-D display from shape table 
  88. If MAP(1,0)=0 Then M(3)=43 Else M(3)=57
  89. If MAP(0,1)=0
  90.    M(4)=58 : M(5)=58
  91. Else 
  92.    M(4)=44 : M(5)=44
  93. End If 
  94. If MAP(1,2)<2 Then M(6)=43 Else M(6)=57
  95. If MAP(2,0)<2 Then M(2)=42 Else M(2)=54
  96. If MAP(1,1)<2 Then M(3)=55 : M(4)=56 : M(5)=56 : M(6)=55
  97. If MAP(2,2)<2 Then M(7)=42 Else M(7)=54
  98. If MAP(3,0)<2 Then M(1)=41 Else M(1)=50
  99. If MAP(2,1)<2 Then M(2)=51 : M(3)=52 : M(4)=53 : M(5)=53 : M(6)=52 : M(7)=51
  100. If MAP(3,2)<2 Then M(8)=41 Else M(8)=50
  101. If MAP(4,0)<2 Then M(0)=40 Else M(0)=45
  102. If MAP(3,1)<2 Then M(1)=46 : M(2)=47 : M(3)=48 : M(4)=49 : M(5)=49 : M(6)=48 : M(7)=47 : M(8)=46
  103. If MAP(4,2)<2 Then M(9)=40 Else M(9)=45
  104. 'display3-D from shape table 
  105. Screen 1
  106. For XX=0 To 4
  107.    Paste Bob XX*32,0,M(XX)
  108. Next 
  109. 'make shape table draw reverse images
  110. For XX=5 To 9
  111.    Paste Bob XX*32,0,Hrev(M(XX))
  112. Next 
  113. ' Display door 
  114. If MAP(1,1)=1 and MAP(2,1)>1 and MAP(3,1)>1 Then Paste Bob 140,100,35
  115. If MAP(2,1)=1 and MAP(3,1)>1 Then Paste Bob 130,90,36
  116. If MAP(3,1)=1 Then Paste Bob 120,80,37
  117. 'test objects display values 
  118. Locate 16,0
  119. Print MAP(3,0);"  ";MAP(3,1);"  ";MAP(3,2);"   "
  120. Locate 16,1
  121. Print MAP(4,0);"  ";MAP(4,1);"  ";MAP(4,2);"   "
  122. If MAP(3,1)=6 and ROBOFLAG>0
  123.    ROBOCOP=1 : ROBOFLAG=ROBOFLAG+1
  124. Else If ROBOFLAG>0
  125.    ROBOCOP=0 : ROBOFLAG=1
  126. End If 
  127. Paste Bob 10,10,1 : Rem place marker for mouse commands
  128. 'Display objects if available in location
  129. For X1=4 To 34
  130.    If ROOM=FLAG(X1) Then Bob X1,200,100,X1
  131. Next 
  132. If ROBOCOP=1 Then Bob 1,120,40,2
  133. Wait Vbl : ABKFLAG=0 : Rem display bobs now 
  134. Gosub CLEARTEXT : Print "FACING ";D$(N)
  135. Return 
  136.  
  137. MAPP:
  138. 'Move in the maze
  139.    NS=0
  140.    If N=1
  141.       Y=Y-1
  142.    Else If N=2
  143.       X=X+1
  144.    Else If N=3
  145.       Y=Y+1
  146.    Else 
  147.       X=X-1
  148.    End If 
  149. Return 
  150.  
  151. MICE:
  152. If ROBOCOP=1
  153.    Locate 0,20 : Print "Stay where you are."
  154.    Print "You will not be harmed."
  155.    Wait 60
  156. End If 
  157. Gosub MICE1
  158. 'Read Command Graphics or keyboard 
  159. If XM>22 and XM<29 and YM>9 and YM<17 or K$="f"
  160.    TEMP=1
  161.    If MAP(3,1)>1
  162.       Print "You travel forward." : Gosub MAPP
  163.    Else If MAP(3,1)=1 and KEYFLAG=1
  164.       Print "You go through the door" : Gosub MAPP : KEYFLAG=0
  165.    Else 
  166.       Print "You can't go in that direction."
  167.    End If 
  168. Else If XM>14 and XM<21 and YM>19 and YM<24 or K$="l"
  169.    TEMP=2 : N=N-1 : Print "You turn to the left"
  170. Else If XM>29 and XM<37 and YM>17 and YM<24 or K$="r"
  171.    TEMP=3 : N=N+1 : Print "You turn to the right."
  172. End If 
  173. If N>4 Then N=1
  174. If N<1 Then N=4
  175. If XM>9 and XM<22 and YM>9 and YM<17 or K$="c" Then TEMP=5 : Rem up 
  176. If XM>9 and XM<33 and YM>31 and YM<39 or K$="d" Then TEMP=6 : Rem down 
  177. If XM>9 and XM<29 and YM>40 and YM<48 or K$="g" Then TEMP=7 : Rem get
  178. If XM>9 and XM<29 and YM>48 and YM<56 or K$="p" Then TEMP=8 : Rem put
  179. If XM>9 and XM<29 and YM>56 and YM<64 or K$="u" Then TEMP=9 : Rem use
  180. 'This line altered for demo
  181. If XM>9 and XM<33 and YM>64 and YM<72 or K$="m" Then Goto MAP
  182. If XM>9 and XM<33 and YM>72 and YM<80 Then TEMP=11 : Rem push 
  183. If TEMP=0
  184.    Bell : Print "There is nothing of interest here."
  185. Else If TEMP=7
  186.    Print "Pick up what?" : Gosub MICE1
  187.    X1=0 : Rem indentify object 
  188.    For Y1=4 To 32
  189.       If ROOM=FLAG(Y1)
  190.          X1=Y1
  191.       End If 
  192.    Next 
  193.    If X1>0 and XM>200 and XM<240 and YM>100 and YM<140 and FLAG(X1)=ROOM
  194.       FLAG(X1)=0 : Bob Off X1 : Wait Vbl : OBJECTS(X1)=OBJECTS(X1)+1
  195.       Print "You pick up the ";OBJECT$(X1) : SCORE=SCORE+10
  196.    Else 
  197.       Print "There is nothing to get here."
  198.    End If 
  199. Else If TEMP=8
  200.    Rem gosub tools
  201.    Print "Put down what?"
  202. Else If TEMP=9
  203.    If MAP(3,1)=1 and OBJECTS(19)>0
  204.       OBJECTS(19)=OBJECTS(19)-1
  205.       Paste Bob 120,80,38 : KEYFLAG=1
  206.    Else 
  207.       Print "Use what item?"
  208.    End If 
  209. Else If TEMP=10
  210.    'Not in effect for demo
  211.    Print "Look at what?" : Gosub MICE1
  212.    MICE3:
  213.    X1=0 : Rem indentify object 
  214.    For Y1=4 To 32
  215.       If ROOM=FLAG(Y1)
  216.          X1=Y1
  217.       End If 
  218.    Next 
  219.    If X>0 and XM>200 and XM<240 and YM>100 and YM<140
  220.       Print "You are looking at a ";OBJECT$(X1)
  221.    Else 
  222.       Rem gosub tools if look is flagged again 
  223.       Print "There is nothing special here."
  224.    End If 
  225. Else If TEMP=11
  226.    Print "Nothing happens."
  227. End If 
  228. Return 
  229.  
  230. MAIN:
  231. Do 
  232. If NS<>N Then Gosub LANDSCAPES
  233. Gosub MICE
  234. If ROBOFLAG>2 Then Exit 
  235. Loop 
  236. Print "You have been arrested by the robocop" : Wait 120
  237. Erase All 
  238. End 
  239.  
  240. INFORMATION:
  241. 'Map key Color values
  242. '0 = Walls, You can't go through them. 
  243. '1 = Door requires key to open 
  244. '2 = Key located here
  245. '3 = Passageways, nothing special here 
  246. '4 = Teleport or Master Control, not used
  247. '5 = Robo Control Computer, not used 
  248. '6 = Robocop Zone, A robocop shows up to block your way
  249. '7 = Explored Area  visible on game map. 
  250. ' Colors 1-6 are set to black as to remain invisible until you go there. 
  251. 'Then, they are replace by color 7.
  252. Screen Open 0,640,200,2,Hires
  253. Curs Off : Flash Off 
  254. Screen Open 2,320,200,8,Lowres
  255. Curs Off : Flash Off 
  256. Load Iff "Map1"
  257. Palette ,0,0,0,0,0,0
  258. Screen Open 1,320,200,32,Lowres
  259. Load Iff "Default"
  260. D$(1)="north." : D$(2)="east." : D$(3)="south." : D$(4)="west."
  261. Load "objects.abk"
  262. For X1=4 To 17
  263.    OBJECTS(X1)=1
  264. Next 
  265. For X1=18 To 34
  266.    OBJECTS(X1)=0
  267. Next 
  268. OBJECTS(20)=1
  269. For X1=1 To 34
  270.    FLAG(X1)=0
  271. Next 
  272. OBJECT$(1)="direction"
  273. OBJECT$(2)="Robocop"
  274. OBJECT$(3)="Burned out Robocop"
  275. OBJECT$(4)="stun gun"
  276. OBJECT$(5)="flashlight"
  277. OBJECT$(6)="tool box"
  278. OBJECT$(7)="remote"
  279. OBJECT$(8)="power pack"
  280. OBJECT$(9)="food module"
  281. OBJECT$(10)="water jug"
  282. OBJECT$(11)="gas mask"
  283. OBJECT$(12)="knife"
  284. OBJECT$(13)="blanket"
  285. OBJECT$(14)="clothes"
  286. OBJECT$(15)="book"
  287. OBJECT$(16)="note"
  288. OBJECT$(17)="tote cart"
  289. OBJECT$(18)="stone"
  290. OBJECT$(19)="key"
  291. OBJECT$(20)="chain mail"
  292. OBJECT$(21)="G"
  293. OBJECT$(22)="R"
  294.  
  295. N=2 : X=5 : Y=5 : Z=1 : NS=0
  296. ROBOFLAG=1 : ROBOCOP=0 : MAPOBJ=1
  297. Paper 0 : Pen 1
  298. Goto MAIN