JGame« back to projects
My high school used to teach game development courses for beginning programmers in ActionScript 3, the primary language used by Adobe Flash. Students frequently had difficulty adjusting from ActionScript to the languages used in the more advanced programming courses (mostly Java). Using Java for game development would have been optimal, except that none of the Java game libraries available were easy enough to learn.
So I made one. JGame is a Java GUI library designed with two overarching goals in mind: remove barriers to entry, and encourage good programming practices. As a consequence, JGame follows a few general design principles:
- Developers shouldn’t have to worry about details relating to drawing graphics, matrix transformations, etc. The point of the course is to teach programming and programming concepts through game design, so implementation details and complicated math only pose a barrier to entry.
- The framework should encourage object-oriented programming and general best practices. Setting up a sensible class hierarchy should be the natural way to structure the program.
- Applications should run as both desktop applications and web applets with little modification.
Here are some of the features that JGame provides out of the box.
- Common actions and declarations, such as “this character should be controlled with the mouse” or “this enemy should move along a given path,” are provided in the form of listeners and controllers that can easily be added to objects. For example, to make an object
characterfollow the mouse, the code is simply
Once students feel comfortable, they are encouraged to look under the hood to see how these functions work, and to implement their own.
- All graphics transformations are done automatically. Objects can be translated, scaled, and rotated about a given anchor point. Once these parameters are set by the developer, JGame automatically performs the trigonometric and matrix computations required to draw the object as desired.
- Loading resources from files—loading and displaying images, loading and playing sounds—is all automatic. This means that students don’t have to worry about filesystem input and output to be able to write their games. (As a technical note: this is all implemented using weak references, so it’s friendly to the garbage collector.)
- And, of course, extensive top-level documentation as well as in-code comments, which students are encouraged to explore.
Two classes at my high school currently use JGame to teach beginning programmers: a web design course and an animation course. As an example, a gallery of student work is available on my teacher’s website.« back to projects