Hello all,
I would love to see an article/discussion on java-gaming.org about constructing a simple, practical 2D game framework.
Target games would be things like Space Invaders, Breakout, PacMan, card games, etc. (scrolling is not a priority). After all these years, this is a topic that surely must have been resolved into a ‘best case’ answer!
Specifically, I would like the framework to:
- Handle the main ‘move/test/redraw’ loop
- Have a base ‘applet’ (or whatever) class and a base ‘actor’ (or whatever) class, whereby actors have abstract methods like ‘move’ and ‘paint’, and the applet takes care of moving and painting them each frame
- How to keep the frame rate smooth
- Discussion over the impact of using Collections vs. arrays of primitive types
- Discussion over different techniques for ‘only redrawing what has changed’
- Can you use VolatileImage effectively with applets and one-bit transparency? What about if you mix in some alpha transparency too - do you have to forgo VolatileImage completely? What is the fastest BufferedImage image type?
- Other optimizations
I have constructed such a framework myself, and my main performance bottleneck seems to be because I try to construct an ‘optimal’ clipping shape (consisting only of the rectangles of actors that have moved) and the java ‘Area’ (specifically, sun.awt.geom.AreaOp.AddOp) class seems pretty slow (however, it’s a good deal faster than doing multiple rectangular copyAreas).
I would gladly submit the source for my framework, but would prefer not to slant the opening discussion