Friday, July 6, 2012

Integration

Level and animation creator editor
application started back in 2009
I have a game engine project that I have been working on since 2009 it's gone through quite a few transformations and iterations. Multiple design changes and I hope it will actually become fully functional sometimes soon but I haven't had much chance to move it forward. This integration effort might help that.

So I was looking back at my old editor code that was written for the engine to do animations and level creation. I found some old bugs that I had never fixed and set about debugging and fixing them which took an hour or two. I also was working on some art in my newer "Pixel Painter" program which I created for drawing pixelated graphics. I've used that drawing program a lot since I started creating that last year. It's very useful and makes drawing images pretty quick but there are a lot of features it lacks including basic undo/redo functionality. Still need to work on that.

So I was testing some graphics out in the editor cause I wanted to see how they looked tiled and together and was desperately wanting the ability to simply edit the tiles I was testing with my drawing program and see the changes appear in the editor. Because of the way I had designed the drawing program I knew I could integrate the two very easily. In fact it was even easier and worked better than I had hoped minus a small piece of optimization code that got in the way.

I set about quickly adding a menu item to a right-click popup for "edit"ing the tile image. Created a new ImageController passing it the tile image after doing some extracting from the resource loader it was in, create my new drawing program class and called the createAndDisplay method giving it it's onClose instructions of JFrame.DISPOSE_ON_CLOSE so that it doesn't exit the entire program when I close the drawing window and viola I had the ability to get my tiles from my map program into my drawing program. Awesomeness!!!!

But when I went to try this out to see if the image would update in the editor with the changes made from the drawing program bang exception. Apparently my editor images were not exactly BufferedImages which is what my drawing program needed to be passed they were indeed SunVolatileImages I was like what the freaking hell. After about an hour of digging around the code tracing through things I came to the source of the problem inside my ImageResource wrapper class. Indeed I had done a little image optimization at some point and had this line in my resource class

image = AssetManager.accelImage(img);

Drawing application "Pixel Painter"
started some time in (2011)
That method turns the BufferedImage into a Volatile image if it's image capabilities say that it's not hardware accelerated. I had run into a problem with another game project that slowed framerates to a crawl because the images weren't accelerated and pretty much had rigged the resource to transform itself to be accelerated if it wasn't already. After making a toggle method where I could specify I didn't want them accelerated and skipping over the acceleration line I reloaded the editor popped some tiles in using drag n drop from my images stash and viola editable tiles in my drawing program that will update in the editor when changed and I could save them as separate files in either program.

There are a bunch of other integration's I want to do now for instance creating new tiles using the drawing program from the editor, editing animations and sprites. Creating tilesets from the editor and editing the tiles with the drawing program which if the above is any indication shouldn't be hard at all. And of course upgrading the editor, I don't have layer support or object placement support. So there is a lot to do there but it's definitely fun and worthwhile to do hopefully it will be able to support games in the future but for right now it's just a little testing tool.

No comments:

Post a Comment