Game engine framework for JavaScript, used to make LineRage.
MIT License
This codebase is extracted from LineRage, a fast-paced Tron-like arcade-style JavaScript game.
It's not a complete working game out of the box, you'll need to implement a lot of your own logic between the glue. There are more complete frameworks out there but this one has some interesting optimizations that could be reused.
Read the docs/Getting-Started.md document for an annotated overview and explanation of the various game blocks.
In ascending order of complexity:
All the source code for these demos is available in the Examples directory. Some of the examples contain TODOs throughout, bonus points if you implement them.
Much of the code is written with performance optimization in mind to support a fast-paced game environment. This means there is some repetition and aesthetically unpleasing code.
Each major component is maintained within its own closure that binds to a
global Game
variable. Generally they're separated into their
own JavaScript files.
The goal is to provide common elementary components for building various types of games in JavaScript.
Game.Camera
Create a viewport canvas inside container
of size width
xheight
pixels.
Game.Time
Static object for maintaining a cached value of time.
Game.Clock
Game.ClockThrottled
Clock that moves no faster than max_timestep
ms.
Game.Timer
Timer relative to a given clock.
var clock = new Game.Clock(); var timer = new Game.Timer(clock); timer.start(); // Do stuff... var seconds_elapsed = timer.stop(); ```
Game.Engine
Much of the glue lives here.
Game.Entity
Game.Input
Manage key bindings in one place, with the ability to globally turn event
listening on or off and create one-time bindings.
Game.Renderer
Bind to a camera
Camera object and create num_layers
Canvas layers
inside the camera container.
Game.StateMachine
Define and traverse the flow of the game experience from navigation menus
to levels or whatever else.
Contributions for these are especially welcome. In approximate order of priority:
This project is released under the MIT license unless otherwise stated (such as
with third-party libraries in externs
).