The engine of CgEvents. CgEvents is a great way to build your own games with with a CG.built-in editor.
The engine takes a *.events file to run.
The .events file is an encoded json which contains a config field and a events field.
{
config: {
stage: {
width: "number",
height: "number",
resolutionPolicy: "showAll" | "exactFit" | "fixedWidth" | "fixedHeight" | "origin",
alignHorizontal: "left" | "center" | "right",
alignVertical: "top" | "middle" | "bottom"
}
},
events: [
{
id: "string",
triggers: [],
checks: [],
actions: []
},
...
]
}
Yon can edit the json with CG.built-in editor to control all your game events.
Each event contains a TRIGGER, some CHECKS, and some ACTION. The event flow works like this: 1. The TRIGGER of the event is triggered by the engine (keyboard pressed, event over, or maybe the hero collides with an enemy) 1. Once the trigger is triggered, the engine then goes check the CHECKS. 1. If all CHECKS pass, the engine executes all the ACTIONS in the event.
let manager = new CgEventManager();
manager.importFromSource('CG.YourProject/yourGame.events')
.then(() => manager.preload())
.then(() => manager.start())
;
We use SemVer for versioning.