Game Engine


See the repository here:

This engine is designed to work best with premade image sequences with transparency that will be used for animation. I based most of the function names off of Flash Actionscript. The game engine operates in the Model-View-Controller pattern of user interaction. That means that all the components will be split into these three categories. Model contains all of the information about the game including lists of objects, their positions, attributes, and much more. View contains the code that actually draws the images to the screen. Controller handles all of the "number crunching" and game logic that makes the game run.

Movie Clips

This is the most important class in the game engine. It contains all of the images in animation sequences and the position, rotation and scale of the objects. The movie clip is capable of loading in many folders of images, organizing them into animations and then telling the view what specific frames to draw, where, and with what transformations.

There are three ways you can create movie clips:

I included useful commands like swapAndResume(animation name) and hitTest(another movie clip) to ease game design.

The Display List

Everytime you create a movie clip, you can add it to the display list. The display list keeps track of all the game objects and draws them to the screen automatically without you having to worry about repaint methods. The display list maintains an order which determines the objects depth, however, there are also layers for more fine tune control of the game object depths.

I included useful commands like addChild(movie clip), removeChild(movie clip), moveLayer(movie clip, new layer) to manipulate the list.

Mouse & Keys

The game engine also keeps internal data structures to keep track of what the player is doing with the mouse and keyboard. There are lists to tell which keys/mouse buttons are pressed down, which keys were just pressed down in the last time step, and a function that returns a direction vector based on which arrow keys are pressed.

back to projects...