Page 1 of 1
(just another) Map Editor
Posted: Fri Apr 24, 2009 3:51 pm
by Hurga
Hi guys
I looked for a map editor, best coded in Purebasic with sourcecode and so on. Nice, easy... But ... didnt found one.
So I decided to code it on my own...
here it is (taraaa)
You can draw maps with 3 layers:
- Background
- Objects
- Function
Functionality
- you can load and save maps and tilesets
- you can export the map to image, text and binary
- language is in german and english
Not working yet
- Other image formats other then bitmap
- Helpfile is very basic and in german - but I hope it is more or less easy enough to work with it
- Output as PureBasic code
Here you can download the current version (0.3)
http://purebasic.stdojedmahr.de/projekt ... or_0.3.zip
about 180k, zipped.
It contains the editor, some maps with tilesets and some examples how to work with the text and binary maps in PB.
Version History
29.4.09 - Version 0.3
added: Change the number of function in the settings
added: resize map and / or tilessize "on the fly"
added: import image as Map
added: support for png and jpg format
added: some verybasic "help"-files in german and english
26.4.09 - Version 0.2
added: Language selection
added: Tileset import is now scalable and can added to the current tiles
changed: Tileset dialog
some changes in the GUI
23.4.09 - Version 0.1
Hope some one can use it.
Feedbacks and suggestions for improvement is welcome.
Posted: Fri Apr 24, 2009 5:16 pm
by Criss
Hey, nice work!
It's cool that you use my jnr-engine.
I have made two mapeditors, but no one is complete.
So, keep up the good work.
Posted: Fri Apr 24, 2009 8:22 pm
by Hurga
Thx Criss
I hope its ok with the engine. I did some small changes on it. But make a comment that the engine is from you.
btw: are you willing to work on it some more? Its quite a bit difficult to climb the stairs cos you have to stay an the exact pixel to go up...
Posted: Sat Apr 25, 2009 2:12 am
by Poshu
Just found the J&R engine on the German forum thanks to this post. could you add some english help or at least a little description for each command?
Posted: Sat Apr 25, 2009 7:15 am
by Hurga
With the final release I make a small english and german help file.
For now, maybe the most important things...
Code: Select all
; MENU
; File
; - New: Creates a New Map
; - Load Map: Loads an already existing Map, the corresponding tileset will be loaded also
; - Map Save: Saves the current Map, the corresponding tileset is saved also
; - Map Save As: Saves the current Map with a different name, the corresponding tileset is saved also
; - Loading Tile: loads a new (single) Tile. the Tile must have the same dimension As the Map Tilesize
; - tileset Loading: loads an Image and cut out new Tiles
; - New tileset: Deletes the current tileset
; - tileset Save: Saves all open Tiles As a New tileset
;
;
; Export Map
; - .. to text: saves the Map As a text (Data.i).
; - .. PB code To: returns the Map As PureBasic code. (Currently not working)
; - .. to Binary: is the Map as a Binary Data. A loader for PureBasic is saved also
; - .. Image To: Save the Map with the current settings as a image.
;
; Quit: Exits the program
;
;
; Tools
; Background -> Function: With this tool syou can assign functions from the background tiles
; The default assignment is made according to the order of the tiles. These can be changed by clicking on an other Tile
;
; Settings: Displays a dialog box in which various settings can be made
;
;
; Help
; , - Help: shows a Help screen (Currently not working)
; - About: Displays information about the program
;
;
;
; The Gadgets on the Main Screen
; Map
; Map Delete: Deletes the contents of the current map, all other settings remain
; Show Grid: displays a grid
; The "Del" button deletes the current field under the mouse on the given layer
;
;
; How is it working
; - You select a tile or tileset first
; - You select on with the mouse
; - You click on the map, it appears there.
;
; You can choose from 3 layers, where to draw
; - Background - alle the drawing
; - Objects - here you can place things as objects (these are not used when doing Backgrund-<function)
; - function - here you have 10 numbers you can assign to a tile. (With "Settigns" you can change the numer later)
; - When you are done, save it and export it into a format you like to use
; - Have fun
;
;
; Map format
; This is the format, the map is saved as' binary '
; - the Size of each element is a bit different on 32bit And 64 bit architectures.
; at 32-bit each field is stored with 4 bytes to 64 bit with 8 byte.
; The first two elements are the x-and y-size of the map
; the Map is stored this way
; From up to down and from left to right, each tiles has 3 values
; the 1st the background - the Index of Image in the tileset
; , 2 the objects placed on the Map - the Index of Image in the tileset
; , 3 the function - As a number starting from 1 To .... You have to define yourself how this functions are used in your program
;
; Or in pseudo-code
; For y = 1 To MapWeight
; For x = 1 To MapWidth
; Map (x, y, background)
; Map (x, y, objects)
; Map (x, y, function)
; Next
; Next
;
Posted: Sat Apr 25, 2009 9:52 am
by Kaeru Gaman
Hurga wrote:Code: Select all
; For y = 1 To MapWeight
; For x = 1 To MapWidth
; Map (x, y, background)
; Map (x, y, objects)
; Map (x, y, function)
; Next
; Next
just a little tip:
the last dimension is the
outermost in memory, the first is the inner.
that means, elements nearby each other in memory are those that differ in the first coordinate,
elements differing in the last coordinate are further away from each other.
when you have really big maps (
I mean really REALLY huge),
it is better to put the layer in the first dimension, and walk the second dimension with the inner loop.
fastest:
Code: Select all
For y = 1 To MapWeight
For x = 1 To MapWidth
Map (background, x, y)
Map (objects, x, y)
Map (function, x, y)
Next
Next
layer innermost, secont the inner loop, last the outer loop
slowest:
Code: Select all
For x = 1 To MapWidth
For y = 1 To MapWeight
Map (x, y, background)
Map (x, y, objects)
Map (x, y, function)
Next
Next
first the outer loop, second inner loop, last the layer
sure, that only matters with REALLY big maps, say, if the map cannot be cached as a whole.
I just wanted to tell you that tip, maybe one day you'll need to know...

Posted: Sat Apr 25, 2009 9:20 pm
by Hurga
Thx Kaeru
I think for this map editor its not needed. But I think thats a very valueable information. I hve in an other proggie some array things that a re used every loop, so I think this will save some time

Posted: Sun Apr 26, 2009 7:33 am
by Criss
@Hurga:
It's ok, when you make some changes.
At the moment, i don't have the time to work on it. I have some other projects to complete.
Posted: Sun Apr 26, 2009 4:19 pm
by Hurga
Ok, here is the next version. (0.2)
These is changed
- added: Language selection
- added: Tileset import is now scaleable and can added to the current tiles
- Changed: Tileset dialog
- some changes in the GUI
(Download see first post)
Any ideas what will be useful for the map editor (it should stay a small and easy one...

)
@criss
I changed mainly the x and y orientation in the map format.
Posted: Sun Apr 26, 2009 8:02 pm
by Kaeru Gaman
Sorry I went wrong!
it's just the other way round!
the last dimension ist the innermost....
Code: Select all
Dim test(3,3,3)
For x=0 To 3
For y=0 To 3
For z=0 To 3
test(x,y,z) = 100*x + 10*y + z
Next
Next
Next
*pointer.Long = @test()
For n=0 To 63
Valu = PeekL( *pointer )
*pointer +4
Debug Valu
Next
... I was fooled by the behaviour of ReDim... why can I change the LAST dimension when it is the innermost? *scratches head*
Posted: Wed Apr 29, 2009 10:25 am
by Hurga
Next version. (see first post)
added: Change the number of function in the settings
added: resize map and / or tilessize "on the fly"
added: import image as Map
added: support for png and jpg format
added: some very basic "help"-files in german and english
added: a zoom function for the map
The "import image as Map" option allows you to import an image and it creates for you the tileset and the map...
Has some one tested it yet?
Any feedbacks?
Posted: Tue May 19, 2009 12:24 am
by J. Baker
Looks good so far. Just wondering, if you export as an image, do you just setup collision/functions at X & Y?
Posted: Tue May 19, 2009 7:31 pm
by Hurga
Hi Baker
Thx
If I export the map as image, I use it more as a preview.
For the game the other ways are quite better

Posted: Tue May 19, 2009 7:53 pm
by J. Baker
Hurga wrote:Hi Baker
Thx
If I export the map as image, I use it more as a preview.
For the game the other ways are quite better

That's what I was thinking but just wanted to verify. I didn't know if there was some new technique to it or not.