Hello, I am trying to make myself a simple map editor, tile based, along the lines of the RPGMaker series. I am working with DBPro, and have been largley teaching myself and have a rudimentary understanding, that is growing daily. I used to be quite adept with MS Basic way back in the day, but I havent retained much, so Im pretty much learning from scratch, just a bit about my skil level, might help, might not?
Now to the problem at hand, I have gotten so far as to be able to map the screen in a simple 'box' statement loop myself, and have worked thru several tutorials(the really good one on this site),got a handle on different vars,loops,and most of the commands needed. Im getting clearer on arrays, I understand thats how the map data is stored. I have been searching for a decent working example and the closest I can get is this bit of code I will present you with......
Rem ***** Main Source File *****
`--------------------------------------------------------------------------------------------
`-******************************************************************************************-
`-*************************************2D Tile Mapping*************************************-
`-******************************************************************************************-
`This code was gleaned from TGC 2D forum, and I have hacked it somewhat, I'm trying to make a map editor
`--------------------------------------------------------------------------------------------
`- INITIALISING -
`--------------------------------------------------------------------------------------------
`setup screen
set display mode 800,600,0
hide mouse
set image colorkey 255,0,255
`set variables
cursor = 999
tilesizex = 32
tilesizey = 32
mapsizex = 800
mapsizey = 600
`set up the map array
dim tiles(20,22)
`load all files
load image "cursorBmp.bmp", cursor
load image "grassBmp.bmp", 1
load image "ltdirtBmp.bmp", 2
load image "ltdirtgrass_btmBmp.bmp", 3
load image "ltdirtgrass_lftBmp.bmp", 4
load image "ltdirtgrass_lwrlftBmp.bmp", 5
load image "ltdirtgrass_lwrrtBmp.bmp", 6
load image "ltdirtgrass_rtBmp.bmp", 7
load image "ltdirtgrass_uprBmp.bmp", 8
load image "ltdirtgrass_uprlftBmp.bmp", 9
load image "ltdirtgrass_uprrtBmp.bmp", 10
load image "waterBmp.bmp", 11
load image "watergrass_btmBmp.bmp", 12
load image "watergrass_lftBmp.bmp", 13
load image "watergrass_lwrlftBmp.bmp", 14
load image "watergrass_lwrrtBmp.bmp", 15
load image "watergrass_rtBmp.bmp", 16
load image "watergrass_uprBmp.bmp", 17
load image "watergrass_uprlftBmp.bmp", 18
load image "watergrass_uprrtBmp.bmp", 19
`makes the map
for y = 1 to 20
for x = 1 to 20
read z
tiles(y,x) = z
next x
next y
`--------------------------------------------------------------------------------------------
`- MAIN LOOP -
`--------------------------------------------------------------------------------------------
do
`clears screen
cls
`get cursorx + cursory
cursorx = mousex()
cursory = mousey()
`sprite the new cursor onto the mouse
sprite cursor, cursorx, cursory, cursor
`sprites the tiles to the screen
for y = 1 to 20
for x = 1 to 22
paste image tiles(y,x), tileposx, tileposy
tileposx = tileposx + 32
n = n + 1
next x
tileposy = tileposy + 32
tileposx = 0
next y
loop
`--------------------------------------------------------------------------------------------
`- SUB ROUTINES + FUNCTIONS -
`--------------------------------------------------------------------------------------------
Map:
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 2, 3, 3, 3, 3, 4,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 5, 1, 1, 1, 1, 6,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 5, 1, 1, 1, 1, 6,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 5, 1, 1, 1, 1, 6,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 5, 1, 1, 1, 1, 6,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10, 7, 8, 8, 8, 8, 9,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
data 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
Now I got this of this forum, and I am sure this is close to what I have to get to but when I try to run this code, pls note I have all the media in the folder, also I havent adjusted the 'map' array yet(if that is the right word), what I mean is the original authors .bmp were named in a different scheme than what I have. I dont care what it looks like I just want to get the tiles up, then I can adjust and arrange.
The main hurdle here for me is the actual function of laying the tiles,I dont really have a good understanding of how it is working in this case(or not as it were..), so.... if any kind soul would like to help enlighten me, Id really appreciate it. Feel free to comment the code, that would really help. Any advice is welcomed.I realise I am may jumping ahead of myself, but its what I am the most stoked to learn to do, and I have always learned just by reverse engineering, its hard for me to remain interested in the learning process if I'm not having fun, ot at least working towards it. I think with a bit of assistance I can get it accomplished, then I'll move on to movement, collision and the like. Thanks for your time. Grais