2d tiled map making

Advanced game related topics
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

2d tiled map making

Post by bfernhout »

I was looking for map making program on the internet and not one tile map making program has a script or export to suit Purebasic.
Until i came across a program TileStudio. Its not realy designed for Purebasic. But it had a build in option to create a exporting script to make the export file ready to use in PureBasic.
The code was not easy but i got it right. And the export is error free as include file for Purebasic (I tested this on PB 5.62)
I uploaded the code to the real programmer for the program ts. Including animation and bounding boxes. Finnaly something thats work.

The program is a zip file that you can unfold where ever you want and run in any folder you want. The learning curve is a little bit hard and not always strait forward but when you got it, its very nice to use it.
The program is downloadable from:
http://tilestudio.sourceforge.net/

When the PureBasic export file is not in the zip file, please e-mail me and i wil send the file to you.
My e-mail: bart_fernhout@hotmail.com
N.B. Do not try the TileStudio2. Its far from complete and the export is only in lua. Unless you know how to use the LUA library.

When i got time i wil make a complete manual including examples to use the Ts.exe program.
From my first self made computer till now I stil like computers.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 2d tiled map making

Post by J. Baker »

I guess you didn't search this forum for one. Anyways, glad you got done what you needed.

viewtopic.php?f=16&t=51017&hilit=tiled
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

Re: 2d tiled map making

Post by JamieVanCadsand »

bfernhout wrote:I was looking for map making program on the internet and not one tile map making program has a script or export to suit Purebasic.
Until i came across a program TileStudio. Its not realy designed for Purebasic. But it had a build in option to create a exporting script to make the export file ready to use in PureBasic.
The code was not easy but i got it right. And the export is error free as include file for Purebasic (I tested this on PB 5.62)
I uploaded the code to the real programmer for the program ts. Including animation and bounding boxes. Finnaly something thats work.

The program is a zip file that you can unfold where ever you want and run in any folder you want. The learning curve is a little bit hard and not always strait forward but when you got it, its very nice to use it.
The program is downloadable from:
http://tilestudio.sourceforge.net/

When the PureBasic export file is not in the zip file, please e-mail me and i wil send the file to you.
My e-mail: bart_fernhout@hotmail.com
N.B. Do not try the TileStudio2. Its far from complete and the export is only in lua. Unless you know how to use the LUA library.

When i got time i wil make a complete manual including examples to use the Ts.exe program.

Hey bfrenhout...,

I plans for the next time, to try understand programming code (or train my self to understand code languale with read it),
so thad i hope to goes from beginner to more expert... now i am train code languale reading, just to read code thad i see
on google or forums per-rule and try play with it (do not think thad i make an 'copy paste' game..., only i try to play with
some codes, to understand programming more)...

Just this is an new training project for my programming study, and at the 'GlazenPui, i plans to try program the game,
called BouncingBall... and at hone, i try more to understand code programming in purebasic to looks at google and
this forum yet...
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: 2d tiled map making

Post by bfernhout »

Jamie that is very good.

Read at much as possible and try to understand why something is done. Then you can copy their code, and adjust it to your need.
When that is working you understand the coding and can go forward.
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: 2d tiled map making

Post by bfernhout »

To jbaker.
I did search the whole Pb forum and your stuff was never comming up. I tryed to search under
- Tile
- Tilemapping
- Tiled
- map making
- map
- maps

None of the above directed me to you page. But luckly you did see mine page.
Thanks for the direction. Many thanks.

N.B. There is a little drawback on a win 10 machine to use the Tiled program. When making a connected image, of a couple of tiles and you copied them, there is no way you can past them.
That is a shame, cause i liked the program a lot. Its easy and fast learning to. And the crap that all other tile map making programs give you is a lot of non essential stuff. wih make the files to big.
I hope you found already a to work with that.

Thanks again. I start reading your comment given and try to work it out.
bart.
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: 2d tiled map making

Post by bfernhout »

For the people who want to use the tiled app. Here a little add on:

This is the translation code for tiled:

Code: Select all

; --------------------------------------------------------
; Tile Studio Definition file for use with PureBasic
; (http://www.purebasic.com/)
;
; PureBasic can include the file. Using IncludeBinary 
; The include must be inclosed by DataSection ...
; EndDataSection.
;
; Version 1.01 - Juli 31, 2018
; Build 0005
; In this file the drawing tile is set with #PB_2DDrawing_Transparent 
; This is done because all tiles are loade as sprite that can handle 
; the transparent color
; Bart Fernhout (bart_fernhout@hotmail.com)
; --------------------------------------------------------

; --- bitmap file ----------------------------------------

#tileset
#tilebitmap graphics\\<TileSetIdentifier>.bmp 320
#end tilebitmap
#end tileset

; --------------------------------------------------------

#file <ProjectName>_include.pb
#; ---------- Generated by Tile Studio ----------
declare MapWidth(map)
declare MapHeight(map)
declare TileWidth(map)
declare TileHeight(map)
declare GetTile (Map, x, y)
declare GetBounds (Map, x, y)
declare DrawTile (Map, x, y, tile)

#tileset
#map
Global LAYER_<TileSetIdentifier>_<MapIdentifier> = (<TileSetNumber> \<\< 8) + <MapNumber>
#end map
#end tileset

#; get map width (tiles)
Procedure MapWidth (map)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
      ProcedureReturn <MapWidth>
#end map
#end tileset
  EndSelect
  
EndProcedure

#; get map height (tiles)
Procedure MapHeight (map)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
      ProcedureReturn <MapHeight>
#end map
#end tileset
  EndSelect
  
EndProcedure

#; get tile width (pixels)
Procedure TileWidth (map)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
     ProcedureReturn <TileWidth>
#end map
#end tileset
  EndSelect
  
EndProcedure

#; get tile height (pixels)
Procedure TileHeight (map)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
      ProcedureReturn <TileHeight>
#end map
#end tileset
  EndSelect
  
EndProcedure


#tileset
Global <TileSetIdentifier>Bitmap = LoadImage (#PB_Any,"graphics\\<TileSetIdentifier>.bmp")
Global <TileSetIdentifier>_Width = <TileWidth>
Global <TileSetIdentifier>_Height = <TileHeight>
Global <TileSetIdentifier>_Count = <TileCount>
Global MaskImage.q = RGB(<TransparentColorR>, <TransparentColorG>, <TransparentColorB>)

Global <TileSetIdentifier>_Columns = ImageWidth(<TileSetIdentifier>Bitmap)/<TileSetIdentifier>_Width
Global <TileSetIdentifier>_Rows = ImageHeight(<TileSetIdentifier>Bitmap)/<TileSetIdentifier>_Height

#;Split all images to a Array
Global Dim <TileSetIdentifier>_Array(<TileSetIdentifier>_Columns * <TileSetIdentifier>_Rows)
#;Draw the image to the screen for sprite picking 
startdrawing(ScreenOutput())
DrawImage (ImageId(<TileSetIdentifier>Bitmap),0,0)
StopDrawing()
z = 0
For y = 0 to <TileSetIdentifier>_Rows-1
  For x = 0 to <TileSetIdentifier>_Columns-1
    <TileSetIdentifier>_Array(z) = GrabSprite(#PB_any,x*<TileSetIdentifier>_Width,y*<TileSetIdentifier>_Height,<TileSetIdentifier>_Width,<TileSetIdentifier>_Height)
    TransparentSpriteColor(<TileSetIdentifier>_Array(z), MaskImage)
	z+1
  next
next

;#Remove the drawing drom the backbuffer
clearscreen(0)

#map
Global Dim <TileSetIdentifier><MapIdentifier>Map (<MapHeight>, <MapWidth>)
Restore <TileSetIdentifier><MapIdentifier>MapData
For y = 0 To <MapHeight> - 1
  For x = 0 To <MapWidth> - 1
    Read.i <TileSetIdentifier><MapIdentifier>Map (y, x)
  Next
Next

DataSection
<TileSetIdentifier><MapIdentifier>MapData:
#mapdata  "\nData.i "  ","  "\nData.i "  "\nData.i "  ""
<TileNumber:"%3d">
#end mapdata
EndDataSection

Global Dim <TileSetIdentifier><MapIdentifier>BoundMap (<MapHeight>, <MapWidth>)
Restore <TileSetIdentifier><MapIdentifier>BoundMapData
For y = 0 To <MapHeight> - 1
  For x = 0 To <MapWidth> - 1
    Read.i <TileSetIdentifier><MapIdentifier>BoundMap (y, x)
  Next
Next

#; tile size: w = <TileWidth>, h = <TileHeight>
DataSection
<TileSetIdentifier><MapIdentifier>BoundMapData:
#mapdata  "\nData.i "  ","  "\nData.i "  "\nData.i "  ""
 <BoundMapValue>
#end mapdata
EndDataSection
#end map


#sequence
#;Animation tile sequence
<TileSetIdentifier>Seq<SequenceNumber>$ = Chr(<SequenceNumber>) + 
#sequencedata  ""   " + "  ""
Chr(<TileNumber>)+Chr(<FrameCount>)
#end sequencedata
#end sequence

global Dim <TileSetIdentifier>Sequences$ (<SequenceCount> + 1)
#sequence "\n"
<TileSetIdentifier>Sequences$ (<SequenceNumber>) = <TileSetIdentifier>Seq<SequenceNumber>$
#end sequence

#map
#; <TileSetIdentifier><MapIdentifier>Layer
#; movement (x, y) = (x = <ScrollX>, y = <ScrollY>) 
#end map

#end tileset


#; get tile number at position (x,y)
Procedure GetTile (map, x, y)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
      ProcedureReturn <TileSetIdentifier><MapIdentifier>Map (y, x) - 1
#end map
#end tileset
  EndSelect
  
EndProcedure

#; get bounds/map code at position (x,y)
procedure GetBounds (map, x, y)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
      ProcedureReturn <TileSetIdentifier><MapIdentifier>BoundMap (y, x)
#end map
#end tileset
  EndSelect
  
EndProcedure

Procedure DrawTile (map, x, y, tile)

  Select map
#tileset
#map
    Case LAYER_<TileSetIdentifier>_<MapIdentifier>
	  DisplayTransparentSprite(<TileSetIdentifier>_Array(tile), x, y)
#end map
#end tileset
  EndSelect
  
EndProcedure

#; ---------- end of generated file ----------
#end file

; --------------------------------------------------------

This code create a 100% pureBasic include file. Just export the file trough Shift F10 select code and then F10 to export the code.
When the notification comming up the creation of PureBasic file is done.
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: 2d tiled map making

Post by bfernhout »

A little extra information.

The file i put online is ment for the TileStudio.
You can download it:
http://tilestudio.sourceforge.net/

Keep in mind this is not TILED who is also a great map editor
I only like this more cause of the exporting option to 100% PureBasic.
From my first self made computer till now I stil like computers.
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 2d tiled map making

Post by J. Baker »

bfernhout wrote:To jbaker.
I did search the whole Pb forum and your stuff was never comming up.
That's ok. Now there's another option with a different tile app. The more the merrier. :D
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: 2d tiled map making

Post by bfernhout »

Thank you.

Tiled is also a option i wil look into. I know there are some more option in tiled and sometimes i think why not do it ourself
and the make one only for PureBasic.
From my first self made computer till now I stil like computers.
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

Re: 2d tiled map making

Post by JamieVanCadsand »

Hey Bart...,

Now i am still in programming level 1 and go forwards to programming level 2.... just i am at my
work (the Glazen Pui Arduin, Vlissingen), Working to write an klad, called for the game named Bouncing Ball...

But with the Sin and Cos, i must still try your code, you get written for my om an paper..., but to evening,
i think i don't get time to try your code, just my Personal Regisure is comming for me..., but i hope to do this to
morrow
or s'weekends (friday, saterday or sunday if i get time to try your code for the radian calculation)...

At my work, i am working on the game, named bouncing ball, still to write the code on an .txt klad document... now i get writted
the Main file and the Lib file in each an .txt doc (now i get two .txt documents, called the Main and the
Lib Script...)

bfernhout wrote:Jamie that is very good.

Read at much as possible and try to understand why something is done. Then you can copy their code, and adjust it to your need.
When that is working you understand the coding and can go forward.
Thanks....,

But for understand high complex code, i think thad i must first grow further to an higher programming level to
understand more complexivity in programming....

In Programming Level 5, i want to learn write software, applications and even build robot machines with arduino and
even work with 3d-printing... But this is for an big time later, now i am still programming level 1 and later hope to goes
from level 1 to level 2 with programming... Even, if i am learn Programming Level 5, My main goal is to be an advanced
hobby programmer at complex graphical and sciensifical 2d and 3d software applications, website(s), 3d printing and
even robot machine building, called with CAD and Arduino... and even work in other languales like C++, Java and
Python...

But this is for an big time later..., first i am focus my self on 2D-Games to learn the basic principles of programming,
use PureBasic to learn programming... now i plans to round up programming level 1 and go rustly to programming level 2...,
in level 2, i hope to train my self in complexer programming techniques sush like platform games like zool and mario and
maby some 2d-librarys (.pbi scripts)...

Thanks for your programming teaching,
To Sunday, Jamie.
Post Reply