Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3
  ignore  |  Print  
  2D Map editor  (Read 37427 times)
0 Members and 1 Guest are viewing this topic.
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Posted 2008-01-20 07:36:22 »

This is a 2D tile based map editor with three levels for overlapping objects. It also has a colour adjust feature to play with the overall Hue, Saturation, and individual red, green, and blue colour channels of the entire scene. The change is cached, so adjusting the colour should have no impact on performance of the map.

Maps are resizeable and can be moved around as well.

All source is included. There is some source in there for things like 'sprites' and 'players' and a 'game', but it's not working yet.

http://juddman.googlepages.com/
Offline Noya

Senior Newbie





« Reply #1 - Posted 2008-01-20 11:58:32 »

The colorization of the scene looks really nice, especially the night-time Smiley
Offline CommanderKeith
« Reply #2 - Posted 2008-01-28 09:06:45 »

Hi Juddman,

This editor looks really good - and I really like the sprites you're using- they're nice and bright and happy.  I was actually just surfing the net trying to find a tilemap editor and tried out a few but they looked so terrible - the sprites they used were pixelated, dated and dark, they weren't open source and they only wanted to save stuff in their own custom XML format and make you load that up somehow - yuk.  I was just about to slip into a depression until I saw this, so thanks for posting it and opening up the source!

The GUI is very clean and crisp by the way (probably the first Swing app using metal LnF that I think looks good). And the hue settings look very useful for changing the mood of the level/map.

I'm looking through the source now. What are your future plans with this editor and your game?

Great job  Cool
Keith

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Powerworks

Innocent Bystander





« Reply #3 - Posted 2008-02-05 23:04:09 »

I was looking for an editor like this, it looks excellent.

Keep up the good work!

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #4 - Posted 2008-02-15 10:23:00 »

Currently working on a set of tiles for a riverbank

I was seriously considering changing the map format to use XML for a while. Smiley

It has been sitting in my computer for a few years actually, only recently i added the ability to shift tiles and resize the scene. That was a burst of spare time and interest that i rarely have for it, so i don't have any plans as such. I do want to make a game of some sort, probably an RPG, eventually... but it won't happen anytime soon

The scenery i did with Macromedia Fireworks, pretty basic stuff. i didn't care about colour pallettes and pixels too much, i just drew a nice area of texture that looked ok and then chopped it up into a grid. (i cheated a bit: if you turn the colour saturation all the way down to greyscale, you can't tell the grass apart from the dirt)

a friend of mine made this sprite sheet for me and said it was ok to give it out as well:
Fri Feb 15 2008 <a href="http://www.cdnexus.deviantart.com/">Christopher James Doman</a>:
<img src="http://juddman.googlepages.com/sprites.gif">
Offline CupOfJoe

Junior Newbie





« Reply #5 - Posted 2008-02-16 05:27:21 »

Hey Juddman, I have been trying to do something like this as well. I love the screenshots, but that's all I got. I downloaded the most recent edition. I tried compiling it in Netbeans and it wouldnt let me. It did compile in BlueJ (Yes I am a noob), but then threw a bunch of exceptions when I tried to run the jar file.  Same thing happens when I try and open it from the desktop, only without as specific error info. I'd love to use and customize this app but until I can open it  all is lost.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
new-host:~XXXXXXXX$ java -jar MapEdit.jar
grass dirt
5 0 tiles/gd1.gif
6 0 tiles/gd2.gif
7 0 tiles/gd3.gif
8 0 tiles/gd4.gif
9 0 tiles/gd5.gif
Exception in thread "main" java.lang.NullPointerException
   at javax.swing.ImageIcon.<init>(ImageIcon.java:138)
   at GraphicsBank.<init>(GraphicsBank.java:68)
   at Scene.loadScene(Scene.java:81)
   at MapEdit.<init>(MapEdit.java:42)
   at MapEdit.main(MapEdit.java:539)






I don't think It matters but Im running Mac OS X 10.5.2
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #6 - Posted 2008-02-16 09:59:59 »

It was a file name in uppercase. (tiles/GD5.gif) I fixed it in this version.
Didn't notice it because the windows filesystem is case insensitive, and that's what i use.

Other than that it looks like you compiled and ran it fine. I don't use netbeans myself, i just use the command line, you can build and run it by browsing to the directory of the .java files and typing:

javac *.java
java MapEdit

on either linux or windows.

New version. Actually, just some new tiles - a riverbank. For the map shown below, open bigScene.dat in the editor
<img src="http://juddman.googlepages.com/pond.jpg/pond-large.jpg">
Offline CommanderKeith
« Reply #7 - Posted 2008-02-16 11:46:44 »

Those look great, thanks. Artistic and programming abilities are pretty rare.

I'm trying to make a diablo-style rpg now. 


I was seriously considering changing the map format to use XML for a while. Smiley

Phew!

Thanks,
Keith

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #8 - Posted 2008-02-16 12:54:54 »

Currently working on some larger trees and tree stumps.
Next coding task i think is to add a tileset editor so that the 'outdoors.dat' etc. files don't need to be edited by hand to add new tiles to the list.
and after that, try to add some smart painting so the user just selects the base tile and the edging is done for them
Offline CupOfJoe

Junior Newbie





« Reply #9 - Posted 2008-02-20 05:52:14 »

Thanks again for sharing this JuddMan. I did indeed get it open but now I have an entirely different question that may need to be moved to a different thread but here goes. I see that the scenes are saved as .dat files but how does one parse or load a .dat file in Java? I mean I understand XMl maps, but I have no clue what a .dat file even looks like in the raw. How do you plan on displaying/loading the .dat file into your game?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #10 - Posted 2008-02-20 09:22:51 »

All files this editor saves are in plain text. (the file extension means nothing, you can use whatever you want. i have used .bak for some older maps for instance)

To read them try Notepad.

got Linux? try Emacs, pico, nano, cat, more, less, kate, vi, or vim.

This is not production quality stuff, so what you see there a simple series of numbers.
There is currently no game, no sprites, no logic, just an array of numbers representing one of the tiles listed in outdoors.dat

Let's take a look at bigscene.dat:

1  
2  
3  
4  
100 100 outdoors.dat
colorization 1.0 1.0 1.0 0.0 1.0
.
26 16 14 14 14 14 20 26 4 10 6 4 26 2 .......



100 100 = width height
outdoors.dat = file describing the tileset
colorization r g b h s= red-multiplier, green-multiplier, blue-multiplier, hue-adjustment (0 - 1 being a full hue cycle), saturation-multiplier

26 16 14 14... = Tile ID's. should be ordered on the map from left to right, top to bottom, layer 1 to layer 3.
<img src="http://juddman.googlepages.com/numz.png">

Let's look at the outdoors.dat file:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Tiles{
26 0 grass
tiles/grass.gif
0 0 null(Erase)
tiles/null.gif
1 0 dirt
tiles/dirt.gif
2 0 flower
tiles/flowr.gif
...
}

Edges{
grass dirt{
5 0 tiles/gd1.gif
6 0 tiles/gd2.gif
...
}


Looking at the second line:
26 = Tile ID (what you see for grass in the map file)
0 = can walk on it in any direction
grass = descriptive name to put on the tooltip.
tiles/grass.gif = the image file.

The edges are not really implemented properly yet, and for instance the river tileset has all of its edges just dumped in tiles. it makes no difference. but anyway:

grass dirt { = names of the two base types these are edges between. Map editor will name the tiles specified within the block 'grass dirt 0' 'grass dirt 1'... and so on...
5 0 tiles/gd1.gif = tile ID "5", walkable, image file is "tiles/gd1.gif"


This was all thrown together as it was made, and probably needs to be thought out and re-done. Maybe in XML  Grin
Offline CupOfJoe

Junior Newbie





« Reply #11 - Posted 2008-02-20 10:16:45 »

Ahh... I see. I did know that there was no game architecture, just a map, but I was wondering how you would load it in the long run. I suppose that you'd just do it the same way you load it here, so I can just take a peek at the source myself, though after seeing you explain what the file has in it (and looking myself) I can pretty much guess. Thanks again, this is a wonderful project that I'll definitely be using and probably tweaking.

Quote
This was all thrown together as it was made, and probably needs to be thought out and re-done. Maybe in XML   

I do like the possibility of using XML for something like this, but as for being thrown together, Rome wasn't built in a day...  and a lot of it was torn down to make way for better.

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #12 - Posted 2008-02-20 10:31:25 »

XML is not particularly quick to parse. Not really a problem till you hit a few megs of data in one file.

But it does have well thought out formatting rules which are something to follow and probably better remember how it all fits together four months down the track, rather than turning your files into token soup like mine Smiley (eg. in outdoors.dat, there is a whole ton of random text before the first Tiles{ block that looks like it is important but is actually ignored completely

i don't expect this to become rome.
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #13 - Posted 2008-03-31 22:54:56 »

really good job on the tile map editor. Im now using it to manage my tile maps, for my game. instead of manually typing out the tile number, im using your tilemap program to do it. I had to tweek the code a bit.

its now something like this.
base layer sets up the Tile (instead of 32 size its 32*6) only can use tiles of type 0 on base layer
layer 1 manages the entity positions. (collision entities trees, rocks). can only use tiles types > 0
layer 2 mangages the particle positions, constant non collision effects. can only use tiles types > 0

dude this is sooo neet.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #14 - Posted 2008-04-11 14:36:48 »

Glad you're finding it useful Smiley

One day i may start an actual game too... one day... perhaps.
But at least i'll have a map maker handy!

On another note, there's a new version - 0.8

You can now zoom in and out.

Actually this feature just sort of happened. i hadn't planned it. i was bored and looking through the code. It's probably done incredibly inefficiently.

Click to Play


You can still edit the map at any zoom level. It's handy to zoom right out to see what your map looks like overall, or to do rough planning of the layout of large areas. Zooming in is maybe not so useful, but if you have an ultra-high resolution monitor, or are working with small tiles, it could be handy.

Now it needs a flood-fill tool.

screenshots & download: http://juddman.googlepages.com/

I am also now just uploading the JAR file rather than a zip. A jar is a zip, but you can double click it to run it. (unless WinRar stole the file association Angry) If you unzip the JAR, and then run 'make.bat', it will recompile a new JAR from the source. (handy if you want to compile against an older JDK).

Edit: added this thingy to tileset:
<img src=http://juddman.googlepages.com/oldtree.png />
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #15 - Posted 2008-04-15 12:17:16 »

New version - 0.9

Added flood fill

Added the missing night time scene to the scenes pack.

RGB, hue and saturation sliders now move to the correct values when a scene is loaded

Now has two toolbars (toolbar was getting too wide). I think the buttons are too big, and may make them smaller.
Unfortunately i haven't found out how to do them properly so although you can dock a toolbar to any edge of the window, you can't put them side by side on the same row. If anyone knows how to do that, please let me know.

Zoom icons are now yellow. easier to see:
<img src="http://juddman.googlepages.com/newtools.gif" />

Todo:
eliminate use of anonymous inner classes (makes an ugly mess of Blah$13.class files)
tileset manager
automatic edging
Offline me

Senior Devvie


Projects: 4


Java games rock!


« Reply #16 - Posted 2008-04-16 07:34:22 »

Hi JuddMan,

Thanks for putting effort into this. I've made an editor once before, but
yours is much better. I like especially the layered technique.

I have one request: Undo button

Best regards from

M.E.

M.E.
--------
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #17 - Posted 2008-04-16 09:35:12 »

It shouldn't be too hard.

i'll put that in next time i'm working on it.
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #18 - Posted 2008-04-18 01:38:56 »

Thanks for putting effort into this.
I agree, this editor is great

if your taking suggestions Cheesy

some of the additions iv made that might be handy to most users.

when increasing the tile map, maybe set the new tile to be either the same as the tile connected to it, or my way of setting the new tile as the "theme" of the scene. (grass, dirt...)
also when i click on new, i set up a input dialog, to ask for the new scene size x*y.

once again juddman brilliant work. love the zoom Cheesy

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline CommanderKeith
« Reply #19 - Posted 2008-04-26 11:40:27 »

Zooming and flood fill make using this much easier, thanks.

By the way, I found heaps of free graphics here: http://reinerstileset.4players.de/ (especially check out the terrain graphics here http://reinerstileset.4players.de/environmentE.html. He also does very nice trees http://reinerstileset.4players.de/animatedE.html)

Your tile sets are great so I'll use them, just thought you might want to know about all the free content which could be used.

This tile map editor rocks, great work  Cool

Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #20 - Posted 2008-05-01 12:17:03 »

Most of those are isometric, which this editor doesn't do. it could probably be hacked in easily but it's not something i am interested in just now. things like the trees would work anywhere though.one of the things on the todo list is a tileset editor.

In the meantime if you want to chuck your own tile into a tileset, just open up gfx/outdoors.dat, and add two lines into the Tiles block...

where it says

58 1 Old Tree
tiles/oldtree.png
}

you can add for example the ani fir tree from that collection like so:


58 1 Old Tree
tiles/oldtree.png
59 1 Ani fir
tiles/fir A ani0001.bmp
}

the transparency won't work though, It looks like they are working within some colour pallette restriction and using the magic colour (horrible, unnatural magenta) as transparent, whereas i am just using gif/png transparency, whatever that happens to be. hooray for the libraries doing all the work!

hacking in magic colour transparency to the graphics bank would not be too hard.
Offline CommanderKeith
« Reply #21 - Posted 2008-05-01 12:25:30 »

Thanks for the info.  I think I'll actually end up using cartoony pokemon terrains since it's so much easier to make characters, menus, and new tiles that match the basic, minimalist non-detailed purposely-pixelly pokemon style. When I get up to making proper maps I'll post a zip file of the images I'll be using in this editor.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #22 - Posted 2008-05-01 12:29:30 »

So I had a play with this, but there doesn't seem to be any way to add your own tiles? You always have to use the ones that are already hardcoded. Similarly, there doesn't seem to be a way of adding/removing layers, so I'm stuck with the hardcoded 3. And there doesn't seem to be any documentation about the map format.

It's slick and all, but don't these limitations make it basically unusable for anyone other than yourself?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #23 - Posted 2008-05-01 12:39:29 »

Started working on undo function.

CommanderKeith, i hacked in the ani fir to the tileset as an example. you can see the modified tileset <a href="http://juddman.googlepages.com/outdoors.dat">here</a>, chuck it in gfx/outdoors.dat. the image i edited a bit to put in gif transparency, and can be seen <a href="http://juddman.googlepages.com/ani0000.gif">here</a>, chuck that in gfx/tiles/
here's a <a href="http://juddman.googlepages.com/ani.png">screenshot</a>.
it's not animated though. that sort of thing i'll leave to the hypothetical game engine for now.

Hi orangy, no theres no tileset editor or chooser. the tileset is defined in gfx/outdoors.dat and my previous post showed how you can hack in your own tiles by adding a couple of lines to it... you can only choose a tileset other than "outdoors.dat" by taking a text editor to the map file. sorry, it's on the potential todo list.

the "documentation" for the map format is on the <a href="http://www.java-gaming.org/topics/2d-map-editor/18068/msg/142922/view.html#msg142922">previous page</a> Smiley it's basically the width, the height, then a whole bunch of numbers indexing the tiles in the tileset, with one line break after each layer. the "colorization" stuff can be ignored if you arent interested in writing that sort of thing into your rendering engine

layers is indeed hardcoded.
Offline CommanderKeith
« Reply #24 - Posted 2008-05-02 18:12:08 »

CommanderKeith, i hacked in the ani fir to the tileset as an example. you can see the modified tileset <a href="http://juddman.googlepages.com/outdoors.dat">here</a>, chuck it in gfx/outdoors.dat. the image i edited a bit to put in gif transparency, and can be seen <a href="http://juddman.googlepages.com/ani0000.gif">here</a>, chuck that in gfx/tiles/
here's a <a href="http://juddman.googlepages.com/ani.png">screenshot</a>.
it's not animated though.

That looks great, thanks for the explanation.

By the way, I don't think it matters about the hard-coded stuff and the way maps are saved - the simplicity of the code makes it easy to just port over the stuff you want and change things to save it in your own format.

Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #25 - Posted 2008-05-03 09:50:47 »

the simplicity of the code makes it easy to just port over the stuff you want and change things to save it in your own format.
yeah i agree, 1 of the things i love about this, is the code simplicity

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #26 - Posted 2008-05-06 14:51:31 »

http://juddman.googlepages.com/Mapedit0.10-JuddMan.jar

I tried to implement undo and redo but it's not working properly yet. what i have tried so far is at the end of the MapComponent.java file, but it's disabled.

This version contains a bit of refactoring of the main MapEdit.java file, partially for readability, but mainly to avoid using anonymous inner classes for the actionListeners. (so it doesn't spit out so many .class files when compiling)

Reduced lines of code in MapEdit.java by 88. I thought the toolbars were getting too big, so which do you prefer?



(seems to be shrunk a little by the forum. <a href="http://juddman.googlepages.com/tooloptions.png">here's full size</a>)

1. old style (but rearranged a bit)

2. compact, borders, 2 rows

3. compact, borders, 1 row

4. compact, no borders, one row.

I like number 4 but it's perhaps a bit too cramped.

If you feel like it, you can try the different styles by adjusting:
1  
2  
   boolean compactToolbars = true;
   boolean borderedButtons = true;

on or off as you like in MapEdit.java
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #27 - Posted 2008-05-06 22:08:22 »

all the button layouts look decent in my opinion.

shame about the undo function.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline JuddMan

Senior Devvie


Medals: 1


Your Ad Here


« Reply #28 - Posted 2008-05-18 07:17:08 »

Undo and redo are working now.

I was originally using a list of states and an index to the current position so that you could redo... it wasnt working out.

It turned out to be a lot simpler and easier to just use two stacks:
1  
2  
   Stack undoStack;
   Stack redoStack;

and call saveUndoState before the user makes any changes to the map.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   void saveUndoState()
   {
      redoStack.clear();
      undoStack.push(map.toIntArray());
   }
   void undo() {
      if(!undoStack.empty()) {
         redoStack.push(map.toIntArray());
         int[][][] i = (int[][][])undoStack.pop();
         map.setAllTiles(i, mapEdit.scene.tileset);
      }
   }
   void redo() {
      if(!redoStack.empty()) {
         undoStack.push(map.toIntArray());
         int[][][] i = (int[][][])redoStack.pop();
         map.setAllTiles(i, mapEdit.scene.tileset);
      }
   }
   


undo/redo seems to break when the map is resized though. a workaround is to save and load the map after any resize


grab here:
juddman.googlepages.com

Also, you can drag the map around with the right mouse button now. you can still just click to center on that point if you dont want to drag.

There's a settings tab, where the colour sliders have been moved to. The other settings do not work yet.

There's a new beach "tile"... it's pretty big. you can see it used in the 'waterScene' map which should be in the jar file.
Offline me

Senior Devvie


Projects: 4


Java games rock!


« Reply #29 - Posted 2008-05-18 19:20:48 »

Hi Juddman,

YEEAH!

The undo/redo works and I have changed a few bits to use it for my project.

Changed: Map.java
   different tilewidth/height
   render changed so that it loads a fixed background that I'm using

TileChooser: tile size

Made my own 'myown.dat' scene using myown tiles.



Again, thank you very much for sharing this!
You will be credited!

Kind regards from

M.E.

M.E.
--------
Pages: [1] 2 3
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xFryIx (57 views)
2014-11-13 12:34:49

digdugdiggy (35 views)
2014-11-12 21:11:50

digdugdiggy (29 views)
2014-11-12 21:10:15

digdugdiggy (23 views)
2014-11-12 21:09:33

kovacsa (46 views)
2014-11-07 19:57:14

TehJavaDev (50 views)
2014-11-03 22:04:50

BurntPizza (50 views)
2014-11-03 18:54:52

moogie (65 views)
2014-11-03 06:22:04

CopyableCougar4 (63 views)
2014-11-01 23:36:41

DarkCart (149 views)
2014-11-01 14:51:03
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!