2D Game Engine Development in HTML5

Textbook readings

Base Engine Framework - Code

Framework for making an Engine object. Check out "JavaScript Patterns" Chapter 5 and 6

Defines public, private, and static functions for an Engine 'class' that can be created.

Support for multiple instances of an Engine

Main Game Loop has the responsibility of updating objects/systems and rendering

Game Object System - Code

Adding Classical Inheritence to JavaScript

Allow for new classes to be extended from existing ones using the extend method

Inherited objects can share the same instance methods as the parent objects and call parent methods using this._super() from the child method

The constructor automatically calls the init() method of the object

CODE - BaseClass.js

CODE - Examples of Class Functionality

JSFiddle - Test examples of Class Functionality

Event API & Event Class

Bind, Trigger, and unbind to events

CODE - Evented.js

Component API

Derives from Evented, so any type of component can register for and recieve events

CODE - Component Class

Game Objects / Entities

Entity also derives from Evented, so it can register for and receive events.

Can be assigned any component by name. It is

CODE - Entity.js