Overview
Jasper 2D, an object-behavior based game engine that allows game devs to share their custom defined behaviors among other game developers to provide a new social aspect towards gaem development.
How it works
Jasper 2D consists of two main components:
-
Objects
- Objects in Jasper have a logical existence.
- They do not have any behavior associated with them initially.
- They can be tagged with a name for reference.
- In short,
An Object is a logical entity and can be composed of any number of Behaviors
-
Behaviors
- Behaviors give character to an object.
- They define an object, how it looks, what it does, how it does it, how it handles events, etc.
- In short,
A Mix of Behaviors Define an Object in the game.
Example
var hero = new Jasper.Object("hero");
hero.addBehavior("moveAround");
Other Components
-
Core
- The Jasper.Core object is the main engine object that takes care of the game loop, all the scenes, layers and objects within it.
- init() must be called on the core to start off the engine.
var gameCore = new Jasper.Core({ canvasHeight: 1200, canvasWidth: 1000, container: "container" }).init();
-
Scene
- The Jasper.Scene forms the next level of heirarchy.
- This splits the game into independent scenes each having its own layers.
- Only one scene can be run at a time.
var gameScene = new Jasper.Scene({ name: "main", worldW: 1200, worldH: 1000, });
gameCore.addScene(gameScene).startScene(gameScene);
-
Layer
- The Jasper.Layer acts a container for all objects that are supposed to be in the same z-level.
- This is because the order of rendering of layers are in the same order that they have been added to Scene.
var arenaLayer = new Jasper.Layer({ name:"arena" }); gameScene.addLayer(arenaLayer);
Phew... Now let's make something
Let's get started working with Jasper 2D!!! On to the tutorial !!!