Edit: Here's the updated code and you can download it as well...
Rem Project: Map Editor
Rem Created: 6/6/06 10:46:14 AM
Rem ***** Main Source File *****
` Set up display
backdrop off
hide mouse
sync on
sync rate 0
set display mode 1024,768,16
randomize timer()
Beginning:
`Set Up GUI
cls
`BackDrop
box 0,0,1024,768,rgb(0,100,0),rgb(0,150,0),rgb(0,210,0),rgb(0,255,0)
img_Back = get_free_image()
get image img_Back,0,0,1024,768
cls
cls
`Menu Strip1
box 0,0,1024,20,rgb(255,0,255),rgb(255,0,255),rgb(255,0,255),rgb(255,0,255)
box 2,2,1022,18,rgb(255,0,255),rgb(100,0,100),rgb(255,0,255),rgb(100,0,100)
Menu_Strip1_Left = 2
Menu_Strip1_Top = 2
Menu_Strip1_Right = 1022
Menu_Strip1_Bottom = 18
img_Menu_Strip1 = get_free_image()
get image img_Menu_Strip1,0,0,1024,20
cls
cls
`Menu Strip1 New Game Button State1
box 2,2,text width("New Game") + 2,18,rgb(255,0,0),rgb(255,0,0),rgb(255,0,0),rgb(255,0,0)
box 4,4,text width("New Game"),16,rgb(255,0,0),rgb(100,0,0),rgb(255,0,0),rgb(100,0,0)
set text size 12
ink rgb(255,255,0),rgb(0,0,0)
text 2,2,"New Game"
MS1_New_Game_Left = 2
MS1_New_Game_Top = 2
MS1_New_Game_Right = text width("New Game") + 2
MS1_New_Game_Bottom = 18
img_MS1_New_GameST1 = get_free_image()
MS1_New_Game_ST = 0
get image img_MS1_New_GameST1,2,2,text width("New Game") + 2,18
cls
cls
`Menu Strip1 New Game Button State2
box 2,2,text width("New Game") + 2,18,rgb(255,255,0),rgb(255,255,0),rgb(255,255,0),rgb(255,255,0)
box 4,4,text width("New Game"),16,rgb(255,255,0),rgb(100,100,0),rgb(255,255,0),rgb(100,100,0)
set text size 12
ink rgb(255,0,0),rgb(0,0,0)
text 2,2,"New Game"
img_MS1_New_GameST2 = get_free_image()
get image img_MS1_New_GameST2,2,2,text width("New Game") + 2,18
cls
cls
`Cursor
ink rgb(255,255,255),rgb(0,0,0)
dot 8,8
circle 8,8,2
line 8,0,8,6
line 16,8,10,8
line 8,16,8,10
line 0,8,6,8
img_Cursor = get_free_image()
get image img_Cursor,0,0,16,16
cls
spr_Cursor = get_free_sprite()
sprite spr_Cursor,mousex(),mousey(),img_Cursor
cls
`Cursor2
ink rgb(0,255,0),rgb(0,0,0)
dot 8,8
circle 8,8,2
line 8,0,8,6
line 16,8,10,8
line 8,16,8,10
line 0,8,6,8
img_Cursor2 = get_free_image()
get image img_Cursor2,0,0,16,16
cls
spr_Cursor2 = get_free_sprite()
sprite spr_Cursor2,mousex(),mousey(),img_Cursor
hide sprite spr_Cursor2
Map_Num = -1
TSet_Num = -1
GridX2 = -1
GridY2 = -1
lyr$ = "0"
do
Continue:
cls
`Paste Background
paste image img_Back,0,0
`Paste Menu Strip1
paste image img_Menu_Strip1,0,0
`Paste MS1 New Game Button
if MS1_New_Game_ST = 0
paste image img_MS1_New_GameST1,2,2
endif
if MS1_New_Game_ST = 1
paste image img_MS1_New_GameST2,2,2
endif
`Paste Cursor
CurX = mousex()
CurY = mousey()
if MS1_New_Game_ST = 1 and mouseclick() = 1 and Map_Num = -1
cls
inc Map_Num,1
inc TSet_Num,1
MP = Map_Num
TS = TSet_Num
hide sprite spr_Cursor
gosub Create_New_World_Sheet
gosub Create_New_TileSet_Sheet
show sprite spr_Cursor
wait 1000
endif
MS1_New_Game_ST = MS1_New_Game_Get_State(CurX,CurY,MS1_New_Game_Left,MS1_New_Game_Top,MS1_New_Game_Right,MS1_New_Game_Bottom)
if Map_Num > -1
paste image img_World_Sheet_Grid,spr_WSGx(0),spr_WSGy(0)
paste image img_TileSet_Sheet_Grid,spr_TSx(m),spr_TSy(0)
if upkey() = 1 then dec TSYScroll,1
if downkey() = 1 then inc TSYScroll,1
if leftkey() = 1 then dec TSXScroll,1
if rightkey() = 1 then inc TSXScroll,1
if inkey$() = "w" then dec YScroll,1
if inkey$() = "s" then inc YScroll,1
if inkey$() = "a" then dec XScroll,1
if inkey$() = "d" then inc XScroll,1
if XScroll > XTile - 1 then XScroll = XTile - 1
if YScroll > YTile - 1 then YScroll = YTile - 1
if XScroll < 0 then XScroll = 0
if YScroll < 0 then YScroll = 0
if TSXScroll > 99 then TSXScroll = 99
if TSYScroll > 19 then TSYScroll = 19
if TSXScroll < 0 then TSXScroll = 0
if TSYScroll < 0 then TSYScroll = 0
if keystate(38) = 1 then input "Layer #--->",lyr$
SL = val(lyr$)
if SL > Layer_S then SL = Layer_S
text 225,5,"Current Layer--->" + str$(SL) + "//" + "HScroll--->" + str$(XScroll) + "//" + "VScroll--->" + str$(YScroll)
for l = 0 to SL
for x = 0 to int(512 / Tile_SizeX)
for y = 0 to int(512 / Tile_SizeY)
if XScroll + x < 0 or YScroll + y < 0
MapDisplay_ARRAY(x,y,l).img = Map_ARRAY(0,0,l).img
MapDisplay_ARRAY(x,y,l).col = Map_ARRAY(0,0,l).col
MapDisplay_ARRAY(x,y,l).t$ = Map_ARRAY(0,0,l).t$
MapDisplay_ARRAY(x,y,l).sel = Map_ARRAY(0,0,l).sel
endif
if XScroll + x > XTile - 1 or YScroll + y > YTile - 1
MapDisplay_ARRAY(x,y,l).img = Map_ARRAY(XTile - 1,YTile - 1,l).img
MapDisplay_ARRAY(x,y,l).col = Map_ARRAY(XTile - 1,YTile - 1,l).col
MapDisplay_ARRAY(x,y,l).t$ = Map_ARRAY(XTile - 1,YTile - 1,l).t$
MapDisplay_ARRAY(x,y,l).sel = Map_ARRAY(XTile - 1,YTile - 1,l).sel
endif
if XScroll + x > -1 and YScroll + y > -1 and XScroll + x < XTile and YScroll + y < YTile
MapDisplay_ARRAY(x,y,l).img = Map_ARRAY(x + XScroll,y + YScroll,l).img
MapDisplay_ARRAY(x,y,l).col = Map_ARRAY(x + XScroll,y + YScroll,l).col
MapDisplay_ARRAY(x,y,l).t$ = Map_ARRAY(x + XScroll,y + YScroll,l).t$
MapDisplay_ARRAY(x,y,l).sel = Map_ARRAY(x + XScroll,y + YScroll,l).sel
if MapDisplay_ARRAY(x,y,l).img > 0
if image exist(MapDisplay_ARRAY(x,y,l).img) = 1
paste image MapDisplay_ARRAY(x,y,l).img,spr_WSGx(0) + (x * Tile_SizeX) + 4,spr_WSGy(0) + (y * Tile_SizeY) + 4 + 32,1
if MapDisplay_ARRAY(x,y,l).sel = 1
text spr_WSGx(0) + (x * Tile_SizeX) + 4,spr_WSGy(0) + (y * Tile_SizeY) + 4 + 32,"Col=" + str$(Map_ARRAY(x,y,l).col)
endif
endif
endif
endif
next y
next x
next l
if LBI(0) > 0
sprite 9996,-6000,-6000,LBI(0)
set sprite 9996,1,1
paste sprite 9996,(spr_WSGx(0) + 4 + 512 + 16) - (Tile_SizeX2 * 2),spr_WSGy(0) + 4 + 512 + 32 + 16
endif
if RBI(0) > 0
sprite 9997,-6000,-6000,RBI(0)
set sprite 9997,1,1
paste sprite 9997,(spr_WSGx(0) + 4 + 512 + 16) - Tile_SizeX2,spr_WSGy(0) + 4 + 512 + 32 + 16
endif
if mousex() > spr_WSGx(0) + 4 and mousex() < spr_WSGx(0) + 4 + 512 - Tile_SizeX
if mousey() > spr_WSGy(0) + 4 + 32 and mousey() < spr_WSGy(0) + 4 + 32 + 512 - Tile_SizeY
GridX = ((CurX - (spr_WSGx(0) + 4)) / Tile_SizeX) + XScroll
GridY = ((CurY - (spr_WSGy(0) + 4 + 32)) / Tile_SizeY) + YScroll
text spr_WSGx(0) + (GridX * Tile_SizeX) + 4,spr_WSGy(0) + (GridY * Tile_SizeY) + 4 + 32,Map_ARRAY(x,y,l).t$
if keystate(29) = 0 and keystate(157) = 0 and shiftkey() = 0 and keystate(19) = 0 and mouseclick() = 1
Map_ARRAY(GridX,GridY,SL).img = LBI(0)
endif
if keystate(29) = 0 and keystate(157) = 0 and shiftkey() = 0 and keystate(19) = 0 and mouseclick() = 2
Map_ARRAY(GridX,GridY,SL).img = RBI(0)
endif
`V
if keystate(47) = 1
LBI(0) = 0
endif
`B
if keystate(48) = 1
RBI(0) = 0
endif
if shiftkey() = 1 and mouseclick() = 1
Map_ARRAY(GridX,GridY,SL).sel = 1
endif
if shiftkey() = 1 and mouseclick() = 2
Sel = 1
if GridX2 = -1 and GridY2 = -1
GridX2 = GridX
GridY2 = GridY
endif
if mx = 0 and my = 0
mx = CurX
my = CurY
endif
ink rgb(255,255,255),0
line mx,my,CurX,my
line mx,my,mx,CurY
line CurX,my,CurX,CurY
line mx,CurY,CurX,CurY
endif
if keystate(19) = 1 and mouseclick() = 1
Map_ARRAY(GridX,GridY,SL).sel = 0
endif
if keystate(19) = 1 and mouseclick() = 2
Sel = 0
if GridX2 = -1 and GridY2 = -1
GridX2 = GridX
GridY2 = GridY
endif
if mx = 0 and my = 0
mx = CurX
my = CurY
endif
ink rgb(255,255,255),0
line mx,my,CurX,my
line mx,my,mx,CurY
line CurX,my,CurX,CurY
line mx,CurY,CurX,CurY
endif
if (keystate(29) = 1 or keystate(157) = 1) and keystate(18) = 1
gosub Tile_Edit
endif
endif
endif
`F
if keystate(29) = 0 and keystate(157) = 0 and shiftkey() = 0 and keystate(33) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
Map_ARRAY(x,y,SL).img = LBI(0)
next y
next x
next l
endif
`Ctrl + F
if (keystate(29) = 1 or keystate(157) = 1) and shiftkey() = 0 and keystate(33) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
Map_ARRAY(x,y,SL).img = RBI(0)
next y
next x
next l
endif
`T
if keystate(29) = 0 and keystate(157) = 0 and shiftkey() = 0 and keystate(20) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).sel = 1
Map_ARRAY(x,y,SL).img = LBI(0)
endif
next y
next x
next l
endif
`Ctrl + T
if (keystate(29) = 1 or keystate(157) = 1) and shiftkey() = 0 and keystate(20) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).sel = 1
Map_ARRAY(x,y,SL).img = RBI(0)
endif
next y
next x
next l
endif
`G
if keystate(29) = 0 and keystate(157) = 0 and keystate(34) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,l).sel = 1
Map_ARRAY(x,y,l).img = LBI(0)
endif
next y
next x
next l
endif
`H
if keystate(29) = 0 and keystate(157) = 0 and keystate(35) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,l).sel = 1
Map_ARRAY(x,y,l).img = RBI(0)
endif
next y
next x
next l
endif
`J
if keystate(29) = 0 and keystate(157) = 0 and keystate(36) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
Map_ARRAY(x,y,l).sel = 0
next y
next x
next l
endif
`K
if keystate(29) = 0 and keystate(157) = 0 and keystate(37) = 1
wait 100
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).img = Map_ARRAY(0,0,SL).img
Map_ARRAY(x,y,SL).img = LBI(0)
endif
next y
next x
endif
`Ctrl + K
if (keystate(29) = 1 or keystate(157) = 1) and keystate(37) = 1
wait 100
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).img = Map_ARRAY(0,0,SL).img and Map_ARRAY(x,y,SL).sel = 1
Map_ARRAY(x,y,SL).img = LBI(0)
endif
next y
next x
endif
`I
if keystate(29) = 0 and keystate(157) = 0 and keystate(23) = 1
wait 100
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).img = Map_ARRAY(0,0,SL).img
Map_ARRAY(x,y,SL).img = RBI(0)
endif
next y
next x
endif
`Ctrl + I
if (keystate(29) = 1 or keystate(157) = 1) and keystate(23) = 1
wait 100
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if Map_ARRAY(x,y,SL).img = Map_ARRAY(0,0,SL).img and Map_ARRAY(x,y,SL).sel = 1
Map_ARRAY(x,y,SL).img = RBI(0)
endif
next y
next x
endif
if mouseclick() = 0 and GridX2 > -1 and GridY2 > -1 and Sel = 1
for x = GridX2 to GridX
for y = GridY2 to GridY
Map_ARRAY(x,y,SL).sel = 1
next y
next x
GridX2 = -1
GridY2 = -1
endif
if mouseclick() = 0 and GridX2 > -1 and GridY2 > -1 and Sel = 0
for x = GridX2 to GridX
for y = GridY2 to GridY
Map_ARRAY(x,y,SL).sel = 0
next y
next x
GridX2 = -1
GridY2 = -1
endif
if (keystate(29) = 1 or keystate(157) = 1) and keystate(46) = 1
wait 100
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
Map_ARRAY(x,y,l).img = 0
next y
next x
next l
endif
for x = 0 to 1
for y = 0 to 3
if TSXScroll + x < 0 or TSYScroll + y < 0
TileSetDisplay_ARRAY(0,x,y).img = TileSet_ARRAY(0,0,0).img
endif
if TSXScroll + x > 99 or TSYScroll + y > 19
TileSetDisplay_ARRAY(0,x,y).img = TileSet_ARRAY(0,99,19).img
endif
if TSXScroll + x < 100 and TSYScroll + y < 20 and TSXScroll + x > -1 and TSYScroll + y > -1
TileSetDisplay_ARRAY(0,x,y).img = TileSet_ARRAY(0,x + TSXScroll,y + TSYScroll).img
if TileSetDisplay_ARRAY(0,x,y).img > 0
if image exist(TileSetDisplay_ARRAY(0,x,y).img) = 1
paste image TileSetDisplay_ARRAY(0,x,y).img,spr_TSx(0) + (x * Tile_SizeX2) + 4,spr_TSy(0) + (y * Tile_SizeY2) + 4 + 32,1
endif
endif
endif
next y
next x
if mousex() > spr_TSx(0) + 4 and mousex() < spr_TSx(0) + 4 + (2 * Tile_SizeX2)
if mousey() > spr_TSy(0) + 4 + 32 and mousey() < spr_TSy(0) + 4 + 32 + (4 * Tile_SizeY2)
GridX = ((CurX - (spr_TSx(0) + 4)) / Tile_SizeX2) + TSXScroll
GridY = ((CurY - (spr_TSy(0) + 4 + 32)) / Tile_SizeY2) + TSYScroll
if mouseclick() = 1
LBI(0) = TileSet_ARRAY(0,GridX,GridY).img
endif
if mouseclick() = 2
RBI(0) = TileSet_ARRAY(0,GridX,GridY).img
endif
endif
endif
`Ctrl + S
if (keystate(29) = 1 or keystate(157) = 1) and keystate(31) = 1
Msave = 1
endif
if Msave = 1
if Current_File$ = ""
st = 1
endif
if Current_File$ <> ""
st = 2
endif
if st = 1
cls
input "Enter Map Name: ",save$
if file exist(save$ + ".txt") = 1
delete file save$ + ".txt"
endif
open to write 1,save$ + ".txt"
write string 1,str$(XTile)
write string 1,str$(YTile)
write string 1,str$(Tile_SizeX)
write string 1,str$(Tile_SizeY)
write string 1,str$(Layer_S)
for x = 0 to 99
for y = 0 to 19
write string 1,get dir$() + "\" + TileSet_ARRAY(0,x,y).img_name$
write string 1,str$(TileSet_ARRAY(0,x,y).img)
write string 1,TileSet_ARRAY(0,x,y).t$
write string 1,str$(TileSet_ARRAY(0,x,y).col)
next y
next x
for l = 0 to 19
for x = 0 to XTile - 1
for y = 0 to YTile - 1
write string 1,str$(Map_ARRAY(x,y,l).img)
write string 1,Map_ARRAY(x,y,l).t$
write string 1,str$(Map_ARRAY(x,y,l).col)
next y
next x
next l
close file 1
Current_File$ = save$ + ".txt"
Msave = 0
st = 0
ink rgb(0,255,0),0
text 800,5,"Saved"
sync
wait 1000
goto Continue
endif
if st = 2
if file exist(Current_File$) = 1
delete file Current_File$
endif
open to write 1,Current_File$
write string 1,str$(XTile)
write string 1,str$(YTile)
write string 1,str$(Tile_SizeX)
write string 1,str$(Tile_SizeY)
write string 1,str$(Layer_S)
for x = 0 to 99
for y = 0 to 19
write string 1,get dir$() + "\" + TileSet_ARRAY(0,x,y).img_name$
write string 1,str$(TileSet_ARRAY(0,x,y).img)
write string 1,TileSet_ARRAY(0,x,y).t$
write string 1,str$(TileSet_ARRAY(0,x,y).col)
next y
next x
for l = 0 to 19
for x = 0 to XTile - 1
for y = 0 to YTile - 1
write string 1,str$(Map_ARRAY(x,y,l).img)
write string 1,Map_ARRAY(x,y,l).t$
write string 1,str$(Map_ARRAY(x,y,l).col)
next y
next x
next l
close file 1
Msave = 0
st = 0
text 800,5,"Saved"
sync
wait 1000
goto Continue
endif
endif
if keystate(16) = 1
wait 100
last_image = get_free_image() - 1
for i = 1 to last_image
if image exist(i) = 1
delete image i
endif
next i
last_sprite = get_free_sprite() - 1
for i = 1 to last_sprite
if sprite exist(i) = 1
delete sprite i
endif
next i
for x = 0 to 99
for y = 0 to 19
TileSet_ARRAY(0,x,y).img = 0
next y
next x
for x = 0 to 1
for y = 0 to 3
TileSetDisplay_ARRAY(0,x,y).img = 0
next y
next x
for l = 0 to 19
for x = 0 to 99
for y = 0 to 99
Map_ARRAY(x,y,l).img = 0
next y
next x
next l
for l = 0 to 19
for x = 0 to 99
for y = 0 to 99
MapDisplay_ARRAY(x,y,l).img = 0
next y
next x
next l
Map_Num = -1
goto Beginning
endif
endif
sprite spr_Cursor,-6000,-6000,img_Cursor
set sprite spr_Cursor,1,1
offset sprite spr_Cursor,sprite width(spr_Cursor) / 2,sprite height(spr_Cursor) / 2
paste sprite spr_Cursor,CurX,CurY
sync
loop
Create_New_World_Sheet:
type UDT_TileAnimation
anim_Start as integer
anim_End as integer
anim_Name$ as string
endtype
type UDT_Vector2
x as integer
y as integer
endtype
type UDT_TSet
spr as integer
img as integer
img_name$ as string
coord as UDT_Vector2
col as integer
animated as UDT_TileAnimation
alpha as integer
t$ as string
sel as integer
endtype
cls
ink rgb(255,0,0),rgb(0,0,0)
color backdrop 0
input "Would you like to load a map?(y / n)",a$
print a$
sync
wait 1000
dim Map_Array(99,99,19) as UDT_TSet
dim MapDisplay_Array(99,99,19) as UDT_TSet
if a$ = "y"
a = 1
cls
dim TileSet_ARRAY(2,99,19) as UDT_TSet
clear entry buffer
perform checklist for files
dim LOAD(199)
repeat
cls
set text size 25
Stop4:
for f = last_stop + 1 to checklist quantity()
print "(" + str$(f) + ")" + checklist string$(f)
if (f - last_stop) * 25 > 600 then last_stop = f - 1:print "Press '1' to continue or press 'b' to go back...":goto Stop3
next f
Stop3:
print get dir$()
sync
input ">Load Map>",L$
if L$ = "b" then last_stop = 0:goto stop4
LD = val(L$)
if LD = 1 then cls:goto Stop4
if LD > 1
if right$(checklist string$(LD),4) = ".txt"
Load(1) = LD
Load(0) = 1
else
set dir checklist string$(LD)
clear entry buffer
perform checklist for files
LD = 0
endif
endif
until LOAD(0) > 0
save$ = get dir$() + "\" + checklist string$(LD)
Current_File$ = save$
if file exist(save$) = 1
open to read 1,save$
read string 1,XSeg$
read string 1,YSeg$
read string 1,XTSize$
read string 1,YTSize$
read string 1,Layers$
XTile = val(XSeg$)
YTile = val(YSeg$)
Tile_SizeX = val(XTSize$)
Tile_SizeY = val(YTSize$)
Layer_S = val(Layers$)
for x = 0 to 99
for y = 0 to 19
read string 1,image$
read string 1,ImgNum$
read string 1,TileSet_ARRAY(0,x,y).t$
read string 1,collide$
if val(ImgNum$) > 0 and file exist(image$) = 1
load image image$,val(ImgNum$)
TileSet_ARRAY(0,x,y).col = val(collide$)
TileSet_ARRAY(0,x,y).img = val(ImgNum$)
TileSet_ARRAY(0,x,y).img_name$ = image$
endif
next y
next x
for l = 0 to 19
for x = 0 to val(XSeg$) - 1
for y = 0 to val(YSeg$) - 1
read string 1,image$
read string 1,Map_ARRAY(x,y,l).t$
read string 1,collision$
Map_ARRAY(x,y,l).img = val(image$)
Map_ARRAY(x,y,l).col = val(collision$)
next y
next x
next l
close file 1
endif
goto Create_MapImage
endif
input "Num of X Segments--->",XSeg$
print XSeg$
sync
wait 1000
input "Num of Y Segments--->",YSeg$
print YSeg$
sync
wait 1000
input "XTile Size--->",XTSize$
print XTSize$
sync
wait 1000
input "YTile Size--->",YTSize$
print YTSize$
sync
wait 1000
Create_MapImage:
cls
input "XTile Size2--->",XTSize2$
print XTSize2$
sync
wait 1000
input "YTile Size2--->",YTSize2$
print YTSize2$
sync
if a$ = "n"
dim TileSet_ARRAY(2,99,19) as UDT_TSet
wait 1000
input "Layers--->",Layers$
print Size$
sync
wait 1000
endif
cls
XTile = val(XSeg$)
YTile = val(YSeg$)
REM 101 x 171 is the tile size for the PlanetCute tileSet
Rem and it needs to be 101 x 50 tile sizes for proper cover.
Tile_SizeX = val(XTSize$)
Tile_SizeY = val(YTSize$)
Tile_SizeX2 = val(XTSize2$)
Tile_SizeY2 = val(YTSize2$)
Layer_S = val(Layers$)
cls
box 60,56,512 + 60 + 20,512 + 56 + 20,rgb(255,255,255),rgb(100,100,100),rgb(255,255,255),rgb(100,100,100)
box 64,60,512 + 64 + 16,512 + 60 + 16,rgb(100,0,0),rgb(190,0,0),rgb(100,0,0),rgb(190,0,0)
box 64,60,512 + 64 + 16,60 + 32,rgb(0,0,255),rgb(0,0,0),rgb(0,0,255),rgb(0,0,0)
box 64,60 + 32,512 + 64,512 + 60 + 32,0,0,0,0
img_World_Sheet_Grid = get_free_image()
for x = 64 to 512 + 64 step Tile_SizeX
for y = 60 + 32 to 512 + 64 + 32 step Tile_SizeY
ink rgb(255,0,255),0
line x,60 + 32,x,512 + 60 + 32
line 64,y,512 + 64,y
next y
next x
get image img_World_Sheet_Grid,60,56,512 + 60 + 20,512 + 56 + 20
cls
dim spr_WSGx(2)
dim spr_WSGy(2)
spr_WSGx(0) = 16
spr_WSGy(0) = 16
l = 0
dim LBI(2)
dim RBI(2)
dim sLBI(2)
dim sRBI(2)
dim LimgX(2)
dim LimgY(2)
dim RimgX(2)
dim RimgY(2)
temp_image = get_free_image()
box 0,0,32,32,0,0,0,0
get image temp_image,0,0,32,32
cls
sLBI(0) = get_free_sprite()
sprite sLBI(0),-6000,-6000,temp_image
sRBI(0) = get_free_sprite()
sprite sRBI(0),-6000,-6000,temp_image
return
Create_New_TileSet_Sheet:
dim TileSet_Name$(2)
for t = 0 to 2
TileSet_Name$(t) = "TILE SET #" + str$(t + 1)
next t
cls
box 0,0,8 + 16 + (2 * Tile_SizeX2),8 + 16 + 32 + (4 * Tile_SizeY2),rgb(255,255,255),rgb(100,100,100),rgb(255,255,255),rgb(100,100,100)
box 4,4,4 + 16 + (2 * Tile_SizeX2),4 + 16 + 32 + (4 * Tile_SizeY2),rgb(100,0,0),rgb(190,0,0),rgb(100,0,0),rgb(190,0,0)
box 4,4,4 + 16 + 32 + (2 * Tile_SizeX2),4 + 32,rgb(0,0,255),rgb(0,0,0),rgb(0,0,255),rgb(0,0,0)
box 4,4 + 32,4 + 16 + (2 * Tile_SizeX2),4 + 16 + 32 + (4 * Tile_SizeY2),0,0,0,0
img_TileSet_Sheet_Grid = get_free_image()
for x = 4 to 4 + 16 + (2 * Tile_SizeX2) step Tile_SizeX2
for y = 4 + 32 to 4 + 16 + 32 + (4 * Tile_SizeY2) step Tile_SizeY2
ink rgb(0,255,0),0
line x,4 + 32,x,4 + 16 + 32 + (4 * Tile_SizeY2)
line 4,y,4 + 16 + (2 * Tile_SizeX2),y
next y
next x
get image img_TileSet_Sheet_Grid,0,0,8 + 16 + (2 * Tile_SizeX2),8 + 16 + 32 + (4 * Tile_SizeY2)
cls
dim TileSetDisplay_ARRAY(2,1,3) as UDT_TSet
dim spr_TSx(2)
dim spr_TSy(2)
spr_TSx(0) = 600
spr_TSy(0) = 16
if a = 0
cls
clear entry buffer
perform checklist for files
dim LOAD(199)
repeat
cls
set text size 25
Stop2:
for f = last_stop + 1 to checklist quantity()
print "(" + str$(f) + ")" + checklist string$(f)
if (f - last_stop) * 25 > 600 then last_stop = f - 1:print "Press '1' to continue or press 'b' to go back...":goto Stop1
next f
Stop1:
print get dir$()
sync
input ">Load TileSet>",L$
if L$ = "b" then last_stop = 0:goto stop2
LD = val(L$)
if LD = 1 then cls:goto Stop2
if LD = 0
cls
for f = 1 to checklist quantity()
if right$(checklist string$(f),4) = ".bmp" or right$(checklist string$(f),4) = ".BMP"
Load(f) = f
Load(0) = 1
endif
next f
endif
if LD > 1
if right$(checklist string$(LD),4) = ".bmp" or right$(checklist string$(LD),4) = ".BMP"
Load(1) = LD
Load(0) = 1
endif
if mid$(checklist string$(LD),len(checklist string$(LD)) - 4) <> "."
set dir checklist string$(LD)
clear entry buffer
perform checklist for files
LD = 0
endif
endif
until LOAD(0) > 0
clear entry buffer
perform checklist for files
y = -1
x = 0
cls
for f = 1 to checklist quantity()
if right$(checklist string$(f),4) = ".bmp" or right$(checklist string$(f),4) = ".BMP"
inc y,1
if y > 18 then inc x,1:y = 0
TileSet_ARRAY(0,x,y).img = get_free_image()
TileSet_ARRAY(0,x,y).img_name$ = checklist string$(f)
load image get dir$() + "\" + checklist string$(f),TileSet_ARRAY(0,x,y).img
endif
next f
cls
endif
return
Tile_Edit:
cls
input "Would you like a collision flag? If so, put in the collision reference. Otherwise, put 0.",a$
print a$
sync
wait 1000
input "Please enter a number or words to assign your tile(s) with--->",a2$
print a2$
sync
wait 1000
for l = 0 to Layer_S
for x = 0 to XTile - 1
for y = 0 to YTile - 1
if a$ = "y" and Map_ARRAY(x,y,l).sel = 1
Map_ARRAY(x,y,l).col = 1
endif
if a$ = "n" and Map_ARRAY(x,y,l).sel = 1
Map_ARRAY(x,y,l).col = 0
endif
if Map_ARRAY(x,y,l).sel = 1
Map_ARRAY(x,y,l).t$ = a2$
endif
next y
next x
next l
return
function get_free_sprite()
num = 0
repeat
inc num,1
until sprite exist(num) = 0
endfunction num
function get_free_image()
num = 0
repeat
inc num,1
until image exist(num) = 0
endfunction num
function MS1_New_Game_Get_State(X,Y,X1,Y1,X2,Y2)
if X > X1 and X < X2
if Y > Y1 and Y < Y2
exitfunction 1
endif
endif
endfunction 0
function Cursor_Col(CX,CY,X,Y,X2,Y2)
if CX > X and CX < X2
if CY > Y and CY < Y2
ret = mouseclick()
endif
endif
endfunction ret
I'm trying that Planet Cute/CutGod game challenge, and my map editor isn't showing the Tiles I load in the TileSet...
The images load when I load the file, and I know cuz I already tested it in the main loop... but it just won't show!!!
The Program will ask you after clicking new game to type in a few input entries for the tiles, size, ect...
Type in this...
X #of tiles---> put: 32
Y #of tiles---> put: 32
XSize1---> put: 101
YSize1---> put:50 <---(Trust me, you do want it to overlap in the map section,just not the tileset section)
NOW FOR THE TILESET DATA ENTRIES:
XSize2---> put: 101
YSize2---> put: 171
finally the layers.
Layers---> put: 4
when it asks you, put the number next to the file...PlanetCute PNG
then put "0" without the quotes to load all the files...
I'm sorry for the messy code and When the files are loading, be patient, the only reason it's slow is for debuging purposes that I forgot to take out the source code. If you think you can see the problem without downloading the project,more power to you, but either way, I need help...
thanks
Mickey III