What are the possible ways of making a level editor?

Started by
8 comments, last by mk.jr.fan 9 years, 2 months ago

Hi I am currently making a fishing game in Java and I wanted to know how I could make a level editor for my game. The game world is divided up into a grid that is used to detect collision. The collision grid basically sorts where the location of each object to make a collision detection more efficient for smaller moving objects.But for solid objects that players can walk on and bump into (like land and sea walls), I plan to make it different where one block of land fills one unit on the grid. The only problem is that I'm not sure how I can place these blocks in a more visual way.

I understand that I could possibly use a text editor and fill the map with 1s and 0s, but I would like the possibility of making a map/level editor. Would it be possible to make an image and let the program interpret that from a file or should I make a level editor in game? Is there any other way to make a level editor?

Any suggestions or help would be appreciated!

Advertisement

Would it be possible to make an image and let the program interpret that from a file

I've done that before, but using MS Paint to make maps for my game was a very annoying process, as it was hard to remember what the different colors meant when I had more than five or six.

or should I make a level editor in game? Is there any other way to make a level editor?

You can use a pre-existing one from the internet (and figure out how to import that editor's map files), create your own polished GUI editor (which can take many months or even years which could otherwise be spent on your game), or you can embed simple editing features in your game directly.

Imagine hitting a button like F12 to go into "editing mode". Then use the mouse to place objects, right-click to remove objects, and use keyboard keys or the mouse wheel to switch the object that you are currently placing.

A simple way I've gone about it, when designing levels, is to just store all of the object locations to a file and read from it when it loads. Add a function to re-read the file and set the new locations in the text editor of your choice, and you can just edit that while in game, and use your function to reset the new positions.

I imagine you can do the same with the grid system you have now. The key point just being to load the level from a file, set some functions to re-read it and set the new locations. You could probably go fancy and set up commands in game to select and move them and write to file from there, depending on if you want an editor for players, or for yourself when designing the game.

The key point being to not hard code the information but to load/save/read it instead. Then you can manipulate it to your hearts desire, whether in-game or not. If you're keeping your level as data, then essentially a level editor just saves/reads from that file, and you can set things up however you'd like to manipulate it in-game, or manually edit the text yourself, then read the file again to set the new locations, but without reloading the entire program.

If you're wanting the editor for personal use, rather than player use, I recommend Tiled. It wouldn't be a live editor, but for just designing tiled levels, it's rather quick and efficient.

Beginner here <- please take any opinions with grain of salt

I've done that before, but using MS Paint to make maps for my game was a very annoying process, as it was hard to remember what the different colors meant when I had more than five or six.

Would you have any tips on how I could dissect an image in java to use it as a level?

A simple way I've gone about it, when designing levels, is to just store all of the object locations to a file and read from it when it loads.

Are you suggesting I make a text map that has numbers and letters to represent what each block on the map represents?


Would you have any tips on how I could dissect an image in java to use it as a level?
Read the image, fetch pixel by pixel, assign tile according to color. If your maps are 50x50, you'd have a 50x50 image, each pixel having a specific color that corresponds to a specific tile. That way you could "draw" maps with paint or anything really.

Java can read pngs, jpgs and gifs by default into a BufferedImage with the ImageIO class, its filled with static utility methods.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

This has nothing to do with your question, and you dont have to answer this if its a private project, but whats the game???


Read the image, fetch pixel by pixel, assign tile according to color. If your maps are 50x50, you'd have a 50x50 image, each pixel having a specific color that corresponds to a specific tile. That way you could "draw" maps with paint or anything really.

I'm having trouble looking for tutorial or information on how i would be able to go through each pixel in an image. Is there somewhere you can point me to or give me a key word to look up?


This has nothing to do with your question, and you dont have to answer this if its a private project, but whats the game???

No problem, it's basically going to be a fishing game that I was going to use to work on making collision checks more efficient. The game world is divided up into a grid that is used to detect collision. The collision grid basically sorts where the location of each object to make a collision detection more efficient for smaller moving objects.

I'm having trouble looking for tutorial or information on how i would be able to go through each pixel in an image. Is there somewhere you can point me to or give me a key word to look up?

http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html

Look at the 'getData' method, returns a Raster object. Now look at Raster methods:

http://docs.oracle.com/javase/7/docs/api/java/awt/image/Raster.html

Have in mind that you could try to use a 3rd party library instead of standard ImageIO, in that case you should look up how that particular library handles the data (say, you could be using SlickUtils, or libGDX, etc).

You should have the JDK installed, that way when you hover over a method in your IDE of choice (Eclipse, Netbeans, IntelliJ IDEA, etc) you'll probably get a javadoc pop up that explains what it does. Start relying on that instead of tutorials and you'll be finding new things in no time.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

You might want to read this thread where i and many others have given lots of useful answers on this subject :

http://www.gamedev.net/topic/664570-programming-a-level-editor/

@TheChubu: Thank you for providing me with a base for my research.

@braindigitalis: That's an interesting post I'll definitely be looking through that.

This topic is closed to new replies.

Advertisement