home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 4: Demo 1 / almathera_demo1.bin / amos / mazerv1.amos / mazerv1.amosSourceCode
AMOS Source Code  |  1995-03-16  |  5KB  |  263 lines

  1. '
  2. '     MAZER v1.0 
  3. '
  4. ' A Simple Maze Game!
  5. '
  6. '    By Ben Ashley 
  7. '
  8. ' -------------------  
  9. ' This program demonstrates how easy it is to create a playable game 
  10. ' in AMOS, without flashy graphics and sound!
  11. '  
  12. ' * A Different maze every time! 
  13. ' * You have bombs, to blow away parts of the maze!  
  14. ' * Computer enemy!  Try to avoid him! 
  15. '
  16. Set Buffer 25
  17. '
  18. Dim MAZE$(80,30) : Dim MAZE(80,30)
  19. Do 
  20.    Screen Open 0,640,256,4,Hires
  21.    Colour 1,$FFF : Colour 2,$FF0
  22.    Curs Off : Flash Off : Hide On : Cls 0
  23.    '
  24.    WALL$=Paper$(2)+" "
  25.    SPAC$=Paper$(0)+" "
  26.    CH1$=Pen$(1)+Paper$(0)+"*"
  27.    BOMBS=3
  28.    '
  29.    '
  30.    N=0
  31.    Repeat 
  32.       For F=0 To 79
  33.          If N=0 or N=29 or F=0 or F=79
  34.             MAZE$(F,N)=WALL$ : MAZE(F,N)=1
  35.          Else 
  36.             R=Rnd(3)
  37.             If R=0
  38.                MAZE(F,N)=1 : MAZE$(F,N)=WALL$
  39.             Else 
  40.                MAZE(F,N)=0 : MAZE$(F,N)=SPAC$
  41.             End If 
  42.          End If 
  43.          Print At(F,N);MAZE$(F,N)
  44.       Next F
  45.       Add N,1
  46.    Until N=30
  47.    '
  48.    Pen 0 : Paper 2
  49.    Print At(0,0);"MAZER - By Ben Ashley, 1992.  Odyssey Software"
  50.    '
  51.    ' Set START Position 
  52.    '
  53.    For X=1 To 5
  54.       For Y=1 To 5
  55.          If MAZE(X,Y)=0
  56.             Goto STA
  57.          End If 
  58.       Next Y
  59.    Next X
  60.    '
  61.    STA:
  62.    '
  63.    ' Set END position 
  64.    '
  65.    For EX=79 To 74 Step -1
  66.       For EY=29 To 25 Step -1
  67.          If MAZE(EX,EY)=0
  68.             Print At(EX,EY);Pen$(1)+Paper$(0)+"E"
  69.             Goto STAR
  70.          End If 
  71.       Next EY
  72.    Next EX
  73.    '
  74.    STAR:
  75.    '
  76.    ' Set up the ENEMY.... 
  77.    '
  78.    For XE=60 To 79
  79.       For YE=20 To 29
  80.          If MAZE(XE,YE)=0
  81.             Goto BEG
  82.          End If 
  83.       Next YE
  84.    Next XE
  85.    '
  86.    BEG:
  87.    '
  88.    ' And the other one... 
  89.    '
  90.    For XE2=10 To 79
  91.       For YE2=6 To 29
  92.          If MAZE(XE2,YE2)=0
  93.             Goto BEGIN
  94.          End If 
  95.       Next YE2
  96.    Next XE2
  97.    '
  98.    BEGIN:
  99.    '
  100.    EN=False
  101.    '
  102.    OX=X : OY=Y : Gosub NEW
  103.    OCX=XE : OCY=YE : Gosub NEW2
  104.    OCX2=XE2 : OCY2=YE2
  105.    '
  106.    Timer=0
  107.    '
  108.    Repeat 
  109.       OX=X : OY=Y
  110.       OCX=XE : OCY=YE
  111.       OCX2=XE2 : OCY2=YE2
  112.       If Key State(78) and MAZE(X+1,Y)=0
  113.          Add X,1
  114.          Gosub NEW
  115.          Goto NEX
  116.       End If 
  117.       If Key State(79) and MAZE(X-1,Y)=0
  118.          Add X,-1
  119.          Gosub NEW
  120.          Goto NEX
  121.       End If 
  122.       If Key State(76) and MAZE(X,Y-1)=0
  123.          Add Y,-1
  124.          Gosub NEW
  125.          Goto NEX
  126.       End If 
  127.       If Key State(77) and MAZE(X,Y+1)=0
  128.          Add Y,1
  129.          Gosub NEW
  130.          Goto NEX
  131.       End If 
  132.       NEX:
  133.       A$=Lower$(Inkey$)
  134.       If A$="b" and BOMBS>0
  135.          Add BOMBS,-1
  136.          A1=0 : A2=0 : A3=0 : A4=0
  137.          If Not X=1
  138.             A1=X-1
  139.          Else 
  140.             A1=X+2
  141.          End If 
  142.          If Not X=78
  143.             A2=X+1
  144.          Else 
  145.             A2=X-2
  146.          End If 
  147.          If Not Y=1
  148.             A3=Y-1
  149.          Else 
  150.             A3=Y+2
  151.          End If 
  152.          If Not Y=28
  153.             A4=Y+1
  154.          Else 
  155.             A4=Y-2
  156.          End If 
  157.          MAZE(A1,Y)=0 : MAZE(A2,Y)=0 : MAZE(X,A3)=0 : MAZE(X,A4)=0
  158.          MAZE$(A1,Y)=SPAC$ : MAZE$(A2,Y)=SPAC$ : MAZE$(X,A3)=SPAC$ : MAZE$(X,A4)=SPAC$
  159.          For F=X-1 To X+1 : For G=Y-1 To Y+1
  160.                Print At(F,G);MAZE$(F,G)
  161.          Next G : Next F
  162.          Gosub NEW
  163.       End If 
  164.       '
  165.       If X<XE and MAZE(XE-1,YE)=0
  166.          Add XE,-1
  167.          Gosub NEW2
  168.          Goto NEXLOOP
  169.       End If 
  170.       If X>XE and MAZE(XE+1,YE)=0
  171.          Add XE,1
  172.          Gosub NEW2
  173.          Goto NEXLOOP
  174.       End If 
  175.       If Y<YE and MAZE(XE,YE-1)=0
  176.          Add YE,-1
  177.          Gosub NEW2
  178.          Goto NEXLOOP
  179.       End If 
  180.       If Y>YE and MAZE(XE,YE+1)=0
  181.          Add YE,1
  182.          Gosub NEW2
  183.          Goto NEXLOOP
  184.       End If 
  185.       '
  186.       NEXLOOP:
  187.       '
  188.       If X<XE2 and MAZE(XE2-1,YE2)=0
  189.          Add XE2,-1
  190.          Gosub NEW3
  191.          Goto NEXLOOP2
  192.       End If 
  193.       If X>XE2 and MAZE(XE2+1,YE2)=0
  194.          Add XE2,1
  195.          Gosub NEW3
  196.          Goto NEXLOOP2
  197.       End If 
  198.       If Y<YE2 and MAZE(XE2,YE2-1)=0
  199.          Add YE2,-1
  200.          Gosub NEW3
  201.          Goto NEXLOOP2
  202.       End If 
  203.       If Y>YE2 and MAZE(XE2,YE2+1)=0
  204.          Add YE2,1
  205.          Gosub NEW3
  206.          Goto NEXLOOP2
  207.       End If 
  208.       '
  209.       NEXLOOP2:
  210.       '
  211.       If X=XE and Y=YE : EN=True : DEAD=True : End If 
  212.       If X=XE2 and Y=YE2 : EN=True : DEAD=True : End If 
  213.       If X=EX and Y=EY : EN=True : DEAD=False : End If 
  214.       Wait 3
  215.    Until EN=True
  216.    '
  217.    Gosub SHATTER
  218.    Cls 0
  219.    '
  220.    If DEAD=True
  221.       Gosub LOSE
  222.    Else 
  223.       Gosub WIN
  224.    End If 
  225.    DEAD=False
  226.    EN=False
  227.    Centre At(,12)+"Press Any Key"
  228.    Clear Key 
  229.    Repeat 
  230.    Until Inkey$<>""
  231. Loop 
  232. '
  233. NEW:
  234. Print At(OX,OY);SPAC$
  235. Print At(X,Y);CH1$
  236. Return 
  237. '
  238. NEW2:
  239. Print At(OCX,OCY);SPAC$
  240. Print At(XE,YE);"O"
  241. Return 
  242. '
  243. NEW3:
  244. Print At(OCX2,OCY2);SPAC$
  245. Print At(XE2,YE2);"O"
  246. Return 
  247. '
  248. SHATTER:
  249. For F=0 To 79 : For G=0 To 29
  250.       If MAZE(F,G)=1
  251.          Print At(F,G);SPAC$
  252.       End If 
  253.    Next G
  254. Next F
  255. Return 
  256. '
  257. WIN:
  258. Centre At(,10)+"Maze completed in "+Str$(Timer/60)+" seconds!"
  259. Return 
  260. '
  261. LOSE:
  262. Centre At(,10)+"Killed by the Maze Monster, after "+Str$(Timer/60)+" seconds!"
  263. Return