interface to tile / map editor?

Previous topic - Next topic

loganite

Hello,

Has anyone done any work interfacing to any well known tile/ map editors like Mappy ?  

Mappy seems to have loads of intefaces to other programming languages but I could not see one for GL Basic yet.

Moru

last time I looked at it Mappy can just create a binary file you read in with your game. There should be lots of documentation on how to do this so shouldn´t be a problem.

Kitty Hello

Any volunteers for writing a loader? ;)

Quentin

you can try

http://www.blitzbase.de/_mapeditor/usa_home.htm

its free. For Blitzbasic. But perhaps someone can transfer it to GLBasic.

loganite

Most of the ones I looked at looked pretty over the top for just simple projects. Then I came across this one which looks ideal.

http://devlinslab.blogspot.com/2007/11/simple-tile-map-editor.html

Kitty Hello

It's not "Devlin", is it?

D2O

#6
Its a nice editor, but only one Layer :(


I like this, http://mapeditor.org/screenshots.html .
Im working on a loader / Translator to byte file
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

jobieadobe

Can this "mapeditor" and "Simple Tile Map Editor" that you mentioned be used with GLBasic?

D2O

Hi jobieadobe,

sorry for my bad english  :)

Its realy simple for " Simple Tile Map Editor"

Here ist a Loader and a example to draw the map.

Code (glbasic) Select

GLOBAL level AS Tsmp
level = smp_loader("test.smp")

LOADANIM "gfx.png",0,32,32


WHILE TRUE



FOR j = 0 TO level.hight-1
FOR i = 0 TO level.width-1

IF level.map[i][j] = 1 THEN DRAWANIM 0, 1,i*level.tilex,j*level.tiley
IF level.map[i][j] = 2 THEN DRAWANIM 0, 2,i*level.tilex,j*level.tiley
IF level.map[i][j] = 3 THEN DRAWANIM 0, 3,i*level.tilex,j*level.tiley
IF level.map[i][j] = 4 THEN DRAWANIM 0, 4,i*level.tilex,j*level.tiley

NEXT
NEXT





SHOWSCREEN
WEND








FUNCTION smp_loader AS Tsmp : l_map$

LOCAL l_temp AS Tsmp
LOCAL l_ctrl
LOCAL l_get
LOCAL l_width, l_hight
LOCAL l_x,l_y

l_temp.name$ = l_map$  // Name übergeben


l_ctrl = OPENFILE(0,l_map$,TRUE) // Überprüfung ob die map vorhanden ist

IF l_ctrl = TRUE

// FOR i = 0 TO 6   /// ersten 7 bytes sind für den Editornamen
// READBYTE 0,l_temp.chr[i] //l_get
// NEXT

READSTR 0,l_temp.version$,7 /// ersten 7 bytes sind für den Editornamen

READBYTE 0,l_temp.sys //l_get

IF CHR$(l_temp.sys) = "B"   //B ist für byte, W für word

READBYTE 0,l_temp.width //l_width
READBYTE 0,l_temp.hight //l_hight

REDIM l_temp.map[l_temp.width][l_temp.hight] //map[l_width][l_hight]
// mapsize[0] = l_width-1
// mapsize[1] = l_hight-1

ELSE
READWORD 0,l_temp.width //l_width
READWORD 0,l_temp.hight //l_hight

REDIM l_temp.map[l_temp.width][l_temp.hight]

// mapsize[0] = l_width-1
// mapsize[1] = l_hight-1
ENDIF

READBYTE 0,l_temp.tilex //tile[0]
READBYTE 0,l_temp.tiley //tile[1]


FOR l_y = 0 TO l_temp.hight -1 //l_hight-1
FOR l_x = 0 TO l_temp.width -1 // l_width-1


READBYTE 0,l_temp.map[l_x][l_y] //map[l_x][l_y]

NEXT
NEXT



ELSE
PRINT "Error: No find file "+l_map$,10,10
PRINT "Push any key",10,30
SHOWSCREEN
KEYWAIT

ENDIF
CLOSEFILE 0



RETURN l_temp
ENDFUNCTION

TYPE Tsmp
name$ //Mapname , Optional
version$ // first 7 bytes
tilex // Tile
tiley
width // Map grösse (Tile unit)
hight
sys // Byte or Word
map[0][0] // Mapdata
ENDTYPE

I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

MrTAToad

Both Moru and myself wrote Mappy loaders.  Without boasting too much, I do think my version is a bit more advanced as it can handle all three file formats that Mappy uses.  The only downside to mine (if you can call it a downside) is that it's all INLINEd code.

Mine should be Code Snippets, whilst Moru's is on his website

Ian Price

D20 - there are a couple of problems with your code -

For starters, using lots of IF statements will slow the routine down -
Code (glbasic) Select

FOR j = 0 TO level.hight-1
   FOR i = 0 TO level.width-1

         IF level.map[i][j] = 1 THEN DRAWANIM 0, 1,i*level.tilex,j*level.tiley
         IF level.map[i][j] = 2 THEN DRAWANIM 0, 2,i*level.tilex,j*level.tiley
         IF level.map[i][j] = 3 THEN DRAWANIM 0, 3,i*level.tilex,j*level.tiley
         IF level.map[i][j] = 4 THEN DRAWANIM 0, 4,i*level.tilex,j*level.tiley

   NEXT
NEXT


This could easily be written as
Code (glbasic) Select

FOR j = 0 TO level.hight-1
   FOR i = 0 TO level.width-1
         DRAWANIM 0, level.map[i][j],i*level.tilex,j*level.tiley
   NEXT
NEXT


However, the biggest problem is that you are drawing (or trying to draw) the ENTIRE level. Depending on the size of the level, this could really slow down your game - only draw what's visible in the screen area. GLB clips the drawing anyway, but it's still calculating the entire level data and whether something should be drawn or not. Use offset variables for X and Y so that you are only drawing the screen from the offsets to the max width and height of the screen in tiles.
I came. I saw. I played.

D2O


German:-----------------------------------------------

Hallo Ian,

ja ich weis.

Es soll nur einfach dagestellt werden wie das ganze im Prinziep funktioniert.

Der Code stellt nur ein Bruchteil vom ganzen dar.

Ich selber benutze einen Draw_Level_in_Screen  Function,
dann kommt noch scrolling mit dazu,
auf "If" verzichte ich meistens und benutze "Select Case",

Felder mit dem wert 0 werden in der "For Next" schleife mit einem "Step" übersprungen.

Das gibt dann wieder richtig speed ;)

Aber es wäre hierfür zu aufwendig, nur um die Laderoutine zu zeigen.

Translate:----------------------------------------------------------------------------------

Hello Ian,

yes I wisely.

It should simply only be worked  like the whole one in the Prinziep.

The code represents only a fraction of the whole one.

I even use a Draw_Level_in_Screen Function,
then, scrolling still comes along to it,
I give up "If" mostly and use "Select Case",

Fields with him/it dear 0 becomes rub jumped in the "For Next" with a "Step."

This then gives speed again right ;)

But it would be for this to costly in order to show only the drawer-routine.
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

Ian Price

SELECT/CASE will also slow down map displaying (especially on handhelds if there are lots of CASE/SELECTs), and will be a bitch to keep typing!

It's easy to write a simple tile loading and displaying routine in just a few lines - no point in passing on bad habits to new users ;)
I came. I saw. I played.