home *** CD-ROM | disk | FTP | other *** search
/ Amoszine 10 / Amoszine 10 (Disk 2 of 3).adf / CE_Best_Engines2.lha / 3d_dungeon / Dungeon_Ed.AMOS / Dungeon_Ed.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1995-11-11  |  6.8 KB  |  213 lines

  1. ' 1992 Gary Crook, 131 Green Drift, Royston, Herts, SG8 5BL                  
  2. ' Tel: (0763) 246469 
  3. ' Map size max = 35x35 units (bigger than Eye Of The Beholder's 32x32!)      
  4. ' thus area = 1225 units.        
  5. ' Files used:                    
  6. '   Dungeon_1.map        - Example file;   
  7. '   Dungeon_Ed_Icons.abk - Buttons for load, save, fill and clr.   
  8. ' Please ensure that the outer perimeter of the map area is all wall   
  9. ' (filled blocks), otherwise strange happenings may occur in 
  10. ' 3D_Dungeon.amos
  11. ' Note that when a .map file is loaded into 3D_Dungeon.amos, the player
  12. ' always starts facing north.  You may want, as an exercise, to allow    
  13. ' then to start facing north, east, south or west. 
  14. Set Buffer 30
  15. Dim ZX(1225),ZY(1225),MAP(1225),TYPE$(2)
  16. Global ZX(),ZY(),MAP(),TYPE$(),MZ,FILE_MAP$,LFILENAME$,CHR_MAX
  17. INIT
  18. MAP_EDIT
  19. End 
  20. Procedure INIT
  21.    Rem ********* Set up the display and screen zones *********
  22.    Dir$="df0:"
  23.    Fade 1 : Wait 1*15
  24.    Load "ta:source_progs/g_crook/Dungeon_Ed_Icons.abk"
  25.    Screen Open 0,320,256,16,Lowres
  26.    Limit Mouse 128,45 To 430,250
  27.    Get Sprite Palette 
  28.    Flash Off : Curs Off : Show 
  29.    Cls 0
  30.    Ink 3
  31.    Pen 10 : Paper 0
  32.    Print At(25,2);"Dungeon Editor"
  33.    Print At(25,3);"by Gary Crook"
  34.    Print At(25,8);"Cell Contents:"
  35.    Pen 6
  36.    Reserve Zone 1229
  37.    For GRID_X=1 To 180 Step 5
  38.       Draw GRID_X,15 To GRID_X,190
  39.    Next GRID_X
  40.    For GRID_Y=15 To 190 Step 5
  41.       Draw 1,GRID_Y To 175,GRID_Y
  42.    Next GRID_Y
  43.    Paste Bob 200,174,1
  44.    Set Zone 1226,200,174 To 232,190
  45.    Paste Bob 240,174,2
  46.    Set Zone 1227,240,174 To 272,190
  47.    Paste Bob 200,150,3
  48.    Set Zone 1228,200,150 To 232,166
  49.    Paste Bob 240,150,4
  50.    Set Zone 1229,240,150 To 272,166
  51.    Z=1
  52.    For ZNE_Y=15 To 185 Step 5
  53.       For ZNE_X=1 To 175 Step 5
  54.          Set Zone Z,ZNE_X,ZNE_Y To ZNE_X+4,ZNE_Y+4
  55.          Inc Z
  56.          ZX(Z-1)=ZNE_X
  57.          ZY(Z-1)=ZNE_Y
  58.       Next ZNE_X
  59.    Next ZNE_Y
  60.    For BLKTYPE=0 To 1
  61.       Read TYPE$(BLKTYPE)
  62.    Next BLKTYPE
  63.    Data "Floor        ","Wall         "
  64.    CHR_MAX=0
  65. End Proc
  66. Procedure MAP_EDIT
  67.    Do 
  68.       MZ=Mouse Zone
  69.       MK=Mouse Key
  70.       If MZ>0 and MZ<1226
  71.          If MZ=STRT
  72.             Print At(25,10);"Start Pos."
  73.          Else 
  74.             Print At(25,10);TYPE$(MAP(MZ))
  75.          End If 
  76.       End If 
  77.       Rem ******** Is the mouse on the grid ? *********
  78.       If MZ>0 and MZ<1226
  79.          Rem ***** Left button fills cell     ********* 
  80.          Rem ***** Right button empties cell  ********* 
  81.          If MK=1
  82.             Ink 12
  83.             Bar ZX(MZ)+1,ZY(MZ)+1 To ZX(MZ)+4,ZY(MZ)+4
  84.             MAP(MZ)=1
  85.          End If 
  86.          If MK=2
  87.             Ink 0
  88.             Bar ZX(MZ)+1,ZY(MZ)+1 To ZX(MZ)+4,ZY(MZ)+4
  89.             MAP(MZ)=0
  90.          End If 
  91.       End If 
  92.       Rem ******** Does the user want to load a .map file? ********* 
  93.       If MZ=1226
  94.          If Mouse Click
  95.             LFILENAME$=Fsel$("*.map","","Load a .map level file")
  96.             If LFILENAME$=""
  97.                Print At(0,24);"FILE NOT LOADED!                    "
  98.                Wait 100
  99.                Print At(0,24);"                                    "
  100.             End If 
  101.             If LFILENAME$<>""
  102.                ' read in start position then map and  
  103.                ' display on screen  
  104.                Open In 1,LFILENAME$
  105.                Print At(0,24);"LOADING MAP DETAILS.....            "
  106.                Input #1,STRT$
  107.                STRT=Val(STRT$)
  108.                For MAPLOOP=1 To 1225
  109.                   Input #1,MAP$
  110.                   MAP(MAPLOOP)=Val(MAP$)
  111.                   If MAP(MAPLOOP)=1
  112.                      Ink 12
  113.                      Bar ZX(MAPLOOP)+1,ZY(MAPLOOP)+1 To ZX(MAPLOOP)+4,ZY(MAPLOOP)+4
  114.                   Else 
  115.                      Ink 0
  116.                      Bar ZX(MAPLOOP)+1,ZY(MAPLOOP)+1 To ZX(MAPLOOP)+4,ZY(MAPLOOP)+4
  117.                   End If 
  118.                   If STRT=MAPLOOP
  119.                      Paste Bob ZX(MAPLOOP),ZY(MAPLOOP),5
  120.                   End If 
  121.                Next MAPLOOP
  122.                Close 1
  123.                Print At(0,24);"MAP FILE LOADED OKAY!               "
  124.                Wait 100
  125.                Print At(0,24);"                                    "
  126.             End If 
  127.          End If 
  128.       End If 
  129.       Rem ******** Does the user want to save their map? ********
  130.       If MZ=1227
  131.          If Mouse Click
  132.             Rem ** The starting cell will be your starting ******
  133.             Rem ** point in the dungeon when loaded into   ******
  134.             Rem ** 3D_Dungeon.amos                         ******
  135.             Print At(0,24);"Use mouse to select starting cell..."
  136.             Repeat 
  137.                MZ=Mouse Zone
  138.                If MZ>0 and MZ<1226
  139.                   If MAP(MZ)=0
  140.                      Bob 1,ZX(MZ),ZY(MZ),5
  141.                   End If 
  142.                End If 
  143.             Until Mouse Click
  144.             SFILENAME$=Fsel$("*.map","Dungeon_1.map","Save a .map level file")
  145.             If SFILENAME$=""
  146.                Print At(0,24);"FILE NOT SAVED!                     "
  147.                Wait 100
  148.                Print At(0,24);"                                    "
  149.             End If 
  150.             If SFILENAME$<>""
  151.                STRT$=Str$(MZ)-" "
  152.                Rem ****** check if file has .map extension *******
  153.                If Right$(SFILENAME$,4)<>".map"
  154.                  SFILENAME$=SFILENAME$+".map"
  155.                End If 
  156.                Open Out 1,SFILENAME$
  157.                ' save starting position then map array  
  158.                Print At(0,24);"SAVING MAP DETAILS.....             "
  159.                Print #1,STRT$
  160.                For MAPLOOP=1 To 1225
  161.                   FILE_MAP$=Str$(MAP(MAPLOOP))-" "
  162.                   Print #1,FILE_MAP$
  163.                Next MAPLOOP
  164.                Close 1
  165.                Print At(0,24);"FILE SAVED!                         "
  166.                Wait 100
  167.                Print At(0,24);"                                    "
  168.             End If 
  169.          End If 
  170.       End If 
  171.       Rem ******** fill grid with walls ***********
  172.       If MZ=1228
  173.          If Mouse Click
  174.             R_U_SURE
  175.             If Param=0
  176.               Goto BY_PASS
  177.             End If 
  178.             Ink 12
  179.             For FIL=1 To 1225
  180.                Bar ZX(FIL)+1,ZY(FIL)+1 To ZX(FIL)+4,ZY(FIL)+4
  181.                MAP(FIL)=1
  182.             Next FIL
  183.          End If 
  184.       End If 
  185.       Rem ********** empty grid of walls (make all floor) ******** 
  186.       If MZ=1229
  187.          If Mouse Click
  188.             R_U_SURE
  189.             If Param=0
  190.               Goto BY_PASS
  191.             End If 
  192.             Ink 0
  193.             For FIL=1 To 1225
  194.                Bar ZX(FIL)+1,ZY(FIL)+1 To ZX(FIL)+4,ZY(FIL)+4
  195.                MAP(FIL)=0
  196.             Next FIL
  197.          End If 
  198.       End If 
  199.    BY_PASS:
  200.    Loop 
  201. End Proc
  202. Procedure R_U_SURE
  203.    OKAY=0
  204.    Print At(0,24);"Are you sure (y/n)?"
  205.    I$=Input$(1)
  206.    I$=Upper$(I$)
  207.    If I$="Y"
  208.       OKAY=1
  209.    Else 
  210.       OKAY=0
  211.    End If 
  212.    Print At(0,24);"                   "
  213. End Proc[OKAY]