• Advertisement
Sign in to follow this  

[java] Game Tools in Java

This topic is 4501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I am a hobbist Java programmer. My current goal is to develop a tile editor for a 2D action game I will be making later this year. This is my current plan: 1. Create a full screen JFrame (nothing fancy, just a frame maxmized in both directions). 2. Divide the content pane into a grid that is 64x64 3. Use the right mouse-click to bring up a JColorChooser dialog box 4. Use the left mouse click to fill in the square 5. Enable F4 to bring up a JFileChooser and save the image I am currently familiar with most Swing components and the fundamentals of Java. My big concern is how to draw to the content pane in the way that I desire and then to be able to save the image in a proper format. Any advice would be apperciated. =)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by guyver23
Hello! I am a hobbist Java programmer. My current goal is to develop a tile editor for a 2D action game I will be making later this year. This is my current plan:

1. Create a full screen JFrame (nothing fancy, just a frame maxmized in both directions).

2. Divide the content pane into a grid that is 64x64

3. Use the right mouse-click to bring up a JColorChooser dialog box

4. Use the left mouse click to fill in the square

5. Enable F4 to bring up a JFileChooser and save the image

I am currently familiar with most Swing components and the fundamentals of Java. My big concern is how to draw to the content pane in the way that I desire and then to be able to save the image in a proper format.

Any advice would be apperciated. =)


First thing I'd point out is: why build a tile editor when you can use any gfx pgm (ms paint on up) to create gfx?

Otherwise, it's generally not a good idea to draw directly on a frame. If you check the sun java tutorials there's one there somewhere about creating custom components. For this type of thing (tile map editor) in the past I've extended a JPanel to hold a big-ass image of the tile map then used mouselisteners and mousemotionlisteners to give the ability to update the tile map data and redraw it etc... Then use a JScrollPane to hold the mapeditor/jpanel. Add the JScrollPane to the Frame, plus a panel for the tool buttons (cut copy paste new open close etc...)

I was going to write up a tutorial about it but never got around to it, unfortunately....

Share this post


Link to post
Share on other sites
Thanks guys... I believe I see what you are saying, and it sounds quite sensible. I am a tad confused on one point, though: What classes do you use to freely draw on the JPanel that you place in the frame? I know that you can use a Graphics object in an applet, but with that work here too?

Thanks! :)

Share this post


Link to post
Share on other sites
Yes, you can draw on the graphics by overiding the draw component method in a JPanel. You should really be studying the swing tutorial. Trust me, it has all the answers you need. And now that I think about it, I think I just added my BufferedImage to the scroll pane and overroad the JScrollpane to update the tilemap model.

This all falls into using the MVC (model view controller) pattern as well, but I don't know much about that....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement