home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1995-11-11 | 6.8 KB | 213 lines |
- ' 1992 Gary Crook, 131 Green Drift, Royston, Herts, SG8 5BL
- ' Tel: (0763) 246469
- ' Map size max = 35x35 units (bigger than Eye Of The Beholder's 32x32!)
- ' thus area = 1225 units.
- ' Files used:
- ' Dungeon_1.map - Example file;
- ' Dungeon_Ed_Icons.abk - Buttons for load, save, fill and clr.
- ' Please ensure that the outer perimeter of the map area is all wall
- ' (filled blocks), otherwise strange happenings may occur in
- ' 3D_Dungeon.amos
- ' Note that when a .map file is loaded into 3D_Dungeon.amos, the player
- ' always starts facing north. You may want, as an exercise, to allow
- ' then to start facing north, east, south or west.
- Set Buffer 30
- Dim ZX(1225),ZY(1225),MAP(1225),TYPE$(2)
- Global ZX(),ZY(),MAP(),TYPE$(),MZ,FILE_MAP$,LFILENAME$,CHR_MAX
- INIT
- MAP_EDIT
- End
- Procedure INIT
- Rem ********* Set up the display and screen zones *********
- Dir$="df0:"
- Fade 1 : Wait 1*15
- Load "ta:source_progs/g_crook/Dungeon_Ed_Icons.abk"
- Screen Open 0,320,256,16,Lowres
- Limit Mouse 128,45 To 430,250
- Get Sprite Palette
- Flash Off : Curs Off : Show
- Cls 0
- Ink 3
- Pen 10 : Paper 0
- Print At(25,2);"Dungeon Editor"
- Print At(25,3);"by Gary Crook"
- Print At(25,8);"Cell Contents:"
- Pen 6
- Reserve Zone 1229
- For GRID_X=1 To 180 Step 5
- Draw GRID_X,15 To GRID_X,190
- Next GRID_X
- For GRID_Y=15 To 190 Step 5
- Draw 1,GRID_Y To 175,GRID_Y
- Next GRID_Y
- Paste Bob 200,174,1
- Set Zone 1226,200,174 To 232,190
- Paste Bob 240,174,2
- Set Zone 1227,240,174 To 272,190
- Paste Bob 200,150,3
- Set Zone 1228,200,150 To 232,166
- Paste Bob 240,150,4
- Set Zone 1229,240,150 To 272,166
- Z=1
- For ZNE_Y=15 To 185 Step 5
- For ZNE_X=1 To 175 Step 5
- Set Zone Z,ZNE_X,ZNE_Y To ZNE_X+4,ZNE_Y+4
- Inc Z
- ZX(Z-1)=ZNE_X
- ZY(Z-1)=ZNE_Y
- Next ZNE_X
- Next ZNE_Y
- For BLKTYPE=0 To 1
- Read TYPE$(BLKTYPE)
- Next BLKTYPE
- Data "Floor ","Wall "
- CHR_MAX=0
- End Proc
- Procedure MAP_EDIT
- Do
- MZ=Mouse Zone
- MK=Mouse Key
- If MZ>0 and MZ<1226
- If MZ=STRT
- Print At(25,10);"Start Pos."
- Else
- Print At(25,10);TYPE$(MAP(MZ))
- End If
- End If
- Rem ******** Is the mouse on the grid ? *********
- If MZ>0 and MZ<1226
- Rem ***** Left button fills cell *********
- Rem ***** Right button empties cell *********
- If MK=1
- Ink 12
- Bar ZX(MZ)+1,ZY(MZ)+1 To ZX(MZ)+4,ZY(MZ)+4
- MAP(MZ)=1
- End If
- If MK=2
- Ink 0
- Bar ZX(MZ)+1,ZY(MZ)+1 To ZX(MZ)+4,ZY(MZ)+4
- MAP(MZ)=0
- End If
- End If
- Rem ******** Does the user want to load a .map file? *********
- If MZ=1226
- If Mouse Click
- LFILENAME$=Fsel$("*.map","","Load a .map level file")
- If LFILENAME$=""
- Print At(0,24);"FILE NOT LOADED! "
- Wait 100
- Print At(0,24);" "
- End If
- If LFILENAME$<>""
- ' read in start position then map and
- ' display on screen
- Open In 1,LFILENAME$
- Print At(0,24);"LOADING MAP DETAILS..... "
- Input #1,STRT$
- STRT=Val(STRT$)
- For MAPLOOP=1 To 1225
- Input #1,MAP$
- MAP(MAPLOOP)=Val(MAP$)
- If MAP(MAPLOOP)=1
- Ink 12
- Bar ZX(MAPLOOP)+1,ZY(MAPLOOP)+1 To ZX(MAPLOOP)+4,ZY(MAPLOOP)+4
- Else
- Ink 0
- Bar ZX(MAPLOOP)+1,ZY(MAPLOOP)+1 To ZX(MAPLOOP)+4,ZY(MAPLOOP)+4
- End If
- If STRT=MAPLOOP
- Paste Bob ZX(MAPLOOP),ZY(MAPLOOP),5
- End If
- Next MAPLOOP
- Close 1
- Print At(0,24);"MAP FILE LOADED OKAY! "
- Wait 100
- Print At(0,24);" "
- End If
- End If
- End If
- Rem ******** Does the user want to save their map? ********
- If MZ=1227
- If Mouse Click
- Rem ** The starting cell will be your starting ******
- Rem ** point in the dungeon when loaded into ******
- Rem ** 3D_Dungeon.amos ******
- Print At(0,24);"Use mouse to select starting cell..."
- Repeat
- MZ=Mouse Zone
- If MZ>0 and MZ<1226
- If MAP(MZ)=0
- Bob 1,ZX(MZ),ZY(MZ),5
- End If
- End If
- Until Mouse Click
- SFILENAME$=Fsel$("*.map","Dungeon_1.map","Save a .map level file")
- If SFILENAME$=""
- Print At(0,24);"FILE NOT SAVED! "
- Wait 100
- Print At(0,24);" "
- End If
- If SFILENAME$<>""
- STRT$=Str$(MZ)-" "
- Rem ****** check if file has .map extension *******
- If Right$(SFILENAME$,4)<>".map"
- SFILENAME$=SFILENAME$+".map"
- End If
- Open Out 1,SFILENAME$
- ' save starting position then map array
- Print At(0,24);"SAVING MAP DETAILS..... "
- Print #1,STRT$
- For MAPLOOP=1 To 1225
- FILE_MAP$=Str$(MAP(MAPLOOP))-" "
- Print #1,FILE_MAP$
- Next MAPLOOP
- Close 1
- Print At(0,24);"FILE SAVED! "
- Wait 100
- Print At(0,24);" "
- End If
- End If
- End If
- Rem ******** fill grid with walls ***********
- If MZ=1228
- If Mouse Click
- R_U_SURE
- If Param=0
- Goto BY_PASS
- End If
- Ink 12
- For FIL=1 To 1225
- Bar ZX(FIL)+1,ZY(FIL)+1 To ZX(FIL)+4,ZY(FIL)+4
- MAP(FIL)=1
- Next FIL
- End If
- End If
- Rem ********** empty grid of walls (make all floor) ********
- If MZ=1229
- If Mouse Click
- R_U_SURE
- If Param=0
- Goto BY_PASS
- End If
- Ink 0
- For FIL=1 To 1225
- Bar ZX(FIL)+1,ZY(FIL)+1 To ZX(FIL)+4,ZY(FIL)+4
- MAP(FIL)=0
- Next FIL
- End If
- End If
- BY_PASS:
- Loop
- End Proc
- Procedure R_U_SURE
- OKAY=0
- Print At(0,24);"Are you sure (y/n)?"
- I$=Input$(1)
- I$=Upper$(I$)
- If I$="Y"
- OKAY=1
- Else
- OKAY=0
- End If
- Print At(0,24);" "
- End Proc[OKAY]