Need help with tile based editor

Hello everyone. I’m working on a tile based game, but I’m not making the game engine right away, instead I’m building the tile editor to export the format I’m looking for and then build the engine around that. I figured I didn’t need to create my own parser and I could just use beanshell (a java interpreter that can be called from java) to load in data from the file. This seems to work well, and I was able to load in beanshell files and see the tiles in the editor and save them by printing out beanshell statements to a output stream. I’m wondering if xml is better then using beanshell, if it is, please tell me. I want to create a tile selector that shows associated tiles next to each other in a 2D grid, I’m not sure how to code this.
And I’m wondering about the size of the tiles, should they be powers of 2? if I could make them small ie. 32x32 it would allow me to add more detail and smaller things to the map, the reason for this is there might be a big 64x64 brick wall tile and a plant tile that only takes up 32x32 pixels, it might be useful to break the brick wall up into 4 32x32 tiles so the small plant can be placed on the map without taking a whole 64x64 tile space and possibly blocking the player when he walks on a part of the tile not occupied by the plant. So how do I break up the tiles and keep the divided tiles in seperate files, but also allow them to be read in a way they can be view side by side in the tile selection grid.

PS: please tell me the width and height of the tiles in secret of mana 2 if you know these specs

[quote]Hello everyone. I’m working on a tile based game, but I’m not making the game engine right away, instead I’m building the tile editor to export the format I’m looking for and then build the engine around that. I figured I didn’t need to create my own parser and I could just use beanshell (a java interpreter that can be called from java) to load in data from the file. This seems to work well, and I was able to load in beanshell files and see the tiles in the editor and save them by printing out beanshell statements to a output stream. I’m wondering if xml is better then using beanshell, if it is, please tell me.
[/quote]
Yes its better. Use the validating SAX parser in the xml api and bind the data directly to a class representing your map.

Just try it. It isn’t that hard.

The tiles size can be any size you choose. Usually you select a minimum tile size then then have your tiles being multiples of this. This isn’t a very big problem and you don’t need to restrict yourself by having all tiles being the same size.

There are some things you are missing here. Depending on the view you are choosing your mapper tool will handle isometric, top-down, side view or fake perspective. You will want to work with lots of things that are not tiles and place them in the map. Flats are images like vegetation, candles animals etc… Sometimes we need to mark positions, lines and poligonal areas in a map with properties attached to them. For example trigers for entering areas or crossing lines. You will want to group content into prefab blocks so you can reusize them later. Otherwise you will be repeating a lot of tiresome handwork. Finaly your map should have layers: floor0, floor1, floor2, middle, ceilling. Alternatively you can assign a z order value to your tiles.

Thanks for the reply. I’ve got the tile selection down (yay!), I was working a lot with creating my own java beans, this seemed difficult after a while, so I just subclassed some JPanels for the tile selector and tile placement editors. I’ll add some features like layers, blocking tiles, and load and save buttons.

But about the triggers, do these cause a script to execute when their called? I remember a game called zzt and the scripting language was very simple, you could set flags in a global namespace which was useful for making plots. Should I make my own scripting language for the triggers? Or can I use bean shell to interact with flags, players, npcs, and other objects?

here’s some code to give you a idea of what I mean:

public class Game {
public Map currentMap;
public HashMap<String, Entity> npcs;
public HashMap<String, Boolean> flags;
public Entity player;

public void update(int elapsed) {
ArrayList triggers = currentMap.getActivatedTriggers();
for(Trigger trigger : triggers) {
trigger.exec(this); // This executes bean shell code which sets variables in this class (npcs, flags, player);
}

updateEntities();

}
}

Thanks again for the reply!

[quote]Thanks for the reply. I’ve got the tile selection down (yay!), I was working a lot with creating my own java beans, this seemed difficult after a while, so I just subclassed some JPanels for the tile selector and tile placement editors. I’ll add some features like layers, blocking tiles, and load and save buttons.

[/quote]
It seams that you can handle yourself in this area.

Well triggers are a piece of code attached to an object in the map that can be either a java class or an interpreted script at your scripting language choice. The reason why they are called triggers is because we don’t call them ourselves. The trigger code is “triggered” when a certain event happens. An event can be many things:

  • Player is on top of a tile where a trigger object is
  • Player as entered a circular area around the trigger object
  • Player has exited a circular area around the trigger object
  • Put a trigger on the player that detects proximity of other npcs
  • Put a trigger on an npc that detects property changes (for example when dead)

There are an infinite number of trigger events since there are an infinite number of conditions that can activate them. Usually a trigger is placed on an empty object on the map or attached to an entity or another map object like a flat. The trigger has then access to lots of info when its triggered, including a reference and the properties of the object he is attached to, its location, etc…

Something like that. Your entity would be able to have an unlimited number of properties of any types and not just boolean flags:

some entity e is obtained;
e.putProperty(“Name”, “Gro”);
e.putProperty(“Agility”, new Integer(15));

Integer agl = (Integer)e.getProperty(“Agility”);
String name = (String)e.getProperty(“Name”);

Your method getActivatedTriggers in here:

currentMap.getActivatedTriggers();

would search every tile or active entity on the map and look for one with triggers that validate their activation conditions then execute their code.

Thanks again. The properties tip for npcs is a great idea! With that information I could make a rpg and do all the rpg related things in the script! I think I’ll read more about using beanshell since I might be able to interact with my classes at runtime, meaning I don’t have to bind a scripting language function to every function in the classes controlling the program.

This is all very good advice, infact I think I’ll print this out! =)

Glad to help. Let us know when you finish your mapper tool or your rpg game.

Hello! I’ve added a layer feature and started using a great tile set my brother made. But for some reason I can’t upload the picture of the editor I have ???

Have you created a project at https://games.dev.java.net/ ?
Where are you trying to upload ?

Actually were not sure if we want to open source it. It’s also not developed yet. Anyway it’s coming along pretty well and I added some more features. It seems that one of the hard parts of making a game is making a suite of tools that work together with the engine perfectly. I’ve heard of this before, I’ve just never really done it! Even though it’s hard it’s still pretty fun =)