Skip to content

Commit

Permalink
GameWindow and Documents
Browse files Browse the repository at this point in the history
Changes:

Added the GameWindow class. Should this have the direct link to the canvas or should the Render system 🤔? (I will ponder this). That said, this will be the container to the window (so maybe it should have all the udpate calls and such, but the renderer should touch it as well). Also added some documentation building to the `docs` folder now.

Issues:

The GameWindow class is going to take some working on to get right. Going to have to do some testing with how it will work with the render system.

Comments:

Add some prepublish scripts to build and deploy the documents. Maybe I can get a hook to a website for this? I don't know quite yet. Also going to have to get Travis-CI working sooner than later. Maybe those will be my tasks for tomorrow
  • Loading branch information
srepollock committed Apr 15, 2018
1 parent 0cd24ad commit 7cc6c9a
Show file tree
Hide file tree
Showing 45 changed files with 7,578 additions and 166 deletions.
173 changes: 143 additions & 30 deletions build/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@

Object.defineProperty(exports, '__esModule', { value: true });

class EngineConfiguration {
constructor(_height, _width) {
this._height = _height;
this._width = _width;
}
get height() {
return this._height;
}
set height(height) {
this._height = height;
}
get width() {
return this._width;
}
set width(width) {
this._width = width;
}
}

(function (ErrorCode) {
ErrorCode[ErrorCode["Error"] = 0] = "Error";
ErrorCode[ErrorCode["EngineInitialization"] = 100] = "EngineInitialization";
ErrorCode[ErrorCode["EnginePreviouslyInitialized"] = 101] = "EnginePreviouslyInitialized";
ErrorCode[ErrorCode["EngineWindowUndefined"] = 101] = "EngineWindowUndefined";
ErrorCode[ErrorCode["EngineStartedEarly"] = 102] = "EngineStartedEarly";
ErrorCode[ErrorCode["EngineRunning"] = 103] = "EngineRunning";
ErrorCode[ErrorCode["EngineStopping"] = 104] = "EngineStopping";
Expand All @@ -28,40 +47,134 @@ function LogInfo(info) {
return info;
}

class EngineArguments {
constructor(height = 0, width = 0) {
this.height = height;
this.width = width;
this.height = height;
this.width = width;
}
}
class Engine {
//#endregion
constructor() {
this.height = 0;
this.width = 0;
if (Engine.instance != null) LogError(exports.ErrorCode.EnginePreviouslyInitialized, "engine has already\
been initialized");
if (!Engine.started) LogError(exports.ErrorCode.EngineStartedEarly, "engine running prior to \
constructor initialization");
Engine.instance = this;
}
static start(height, width, ready) {
constructor(args) {
this.started = false;
this.exit = false;
this._height = 0;
this._width = 0;
this._window = undefined;
this._height = args.height;
this._width = args.width;
}
get getStarted() {
return this.started;
}
get height() {
return this._height;
}
get width() {
return this._width;
}
get window() {
if (this._window) return this._window;
LogError(exports.ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
return undefined;
}
start() {
this.started = true;
new Engine();
Engine.resize(height, width);
return this.instance;
}
static stop() {
Engine.exit = true;
}
static resize(height, width) {
Engine.instance.height = height;
Engine.instance.width = width;
// TODO: Resize
/**
* if(!Window.resize()) {
* LogError(ErrorCode.WindowResizeFailed);
* }
*/
if (!this._window) LogError(exports.ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
}
update() {}
stop() {
this.exit = true;
}
resize(height, width) {
if (this._window) {
this._height = height;
this._width = width;
this._window.resize(this._height, this._width);
} else {
LogError(exports.ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
}
}
}

class GameWindow {
constructor(title = "", _height = 0, _width = 0) {
this.title = title;
this._height = _height;
this._width = _width;
this.title = title;
this._height = _height;
this._width = _width;
}
get height() {
return this._height;
}
get width() {
return this._width;
}
resize(height, width) {
this._height = height;
this._width = width;
}
}

class DObject {
constructor(id = "") {
this.id = id;
this.id = id;
}
}

class Transform {
constructor(x = 0, y = 0) {
this.x = x;
this.y = y;
this.x = x;
this.y = y;
}
}
class Entity extends DObject {
constructor(id = "", transform = new Transform(), children = new Array(), components = new Array()) {
super(id);
this.transform = transform;
this.children = children;
this.components = components;
this.transform = transform;
this.children = children;
this.components = components;
}
addComponents(...components) {
for (let comp of components) {
this.components.push(comp);
}
}
hasComponent(type) {
let comp = this.components.find(comp => comp.id === type);
if (comp !== undefined) return true;else return false;
}
}

class FlagComponent {
constructor(location = new Transform()) {
this.location = location;
this.id = "FlagComponent";
this.flagnumber = ++FlagComponent.s_flagnumber;
this.location = location;
}
getFlagnumber() {
return this.flagnumber;
}
}
Engine.started = false;
Engine.exit = false;
FlagComponent.s_flagnumber = 0;

exports.Engine = Engine;
exports.EngineArguments = EngineArguments;
exports.GameWindow = GameWindow;
exports.DObject = DObject;
exports.Entity = Entity;
exports.Transform = Transform;
exports.EngineConfiguration = EngineConfiguration;
exports.LogError = LogError;
exports.LogInfo = LogInfo;
exports.FlagComponent = FlagComponent;
172 changes: 139 additions & 33 deletions build/daemon.module.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
class EngineConfiguration {
constructor(_height, _width) {
this._height = _height;
this._width = _width;
}
get height() {
return this._height;
}
set height(height) {
this._height = height;
}
get width() {
return this._width;
}
set width(width) {
this._width = width;
}
}

var ErrorCode;
(function (ErrorCode) {
ErrorCode[ErrorCode["Error"] = 0] = "Error";
ErrorCode[ErrorCode["EngineInitialization"] = 100] = "EngineInitialization";
ErrorCode[ErrorCode["EnginePreviouslyInitialized"] = 101] = "EnginePreviouslyInitialized";
ErrorCode[ErrorCode["EngineWindowUndefined"] = 101] = "EngineWindowUndefined";
ErrorCode[ErrorCode["EngineStartedEarly"] = 102] = "EngineStartedEarly";
ErrorCode[ErrorCode["EngineRunning"] = 103] = "EngineRunning";
ErrorCode[ErrorCode["EngineStopping"] = 104] = "EngineStopping";
Expand All @@ -25,38 +44,125 @@ function LogInfo(info) {
return info;
}

class EngineArguments {
constructor(height = 0, width = 0) {
this.height = height;
this.width = width;
this.height = height;
this.width = width;
}
}
class Engine {
//#endregion
constructor() {
this.height = 0;
this.width = 0;
if (Engine.instance != null) LogError(ErrorCode.EnginePreviouslyInitialized, "engine has already\
been initialized");
if (!Engine.started) LogError(ErrorCode.EngineStartedEarly, "engine running prior to \
constructor initialization");
Engine.instance = this;
}
static start(height, width, ready) {
constructor(args) {
this.started = false;
this.exit = false;
this._height = 0;
this._width = 0;
this._window = undefined;
this._height = args.height;
this._width = args.width;
}
get getStarted() {
return this.started;
}
get height() {
return this._height;
}
get width() {
return this._width;
}
get window() {
if (this._window) return this._window;
LogError(ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
return undefined;
}
start() {
this.started = true;
new Engine();
Engine.resize(height, width);
return this.instance;
}
static stop() {
Engine.exit = true;
}
static resize(height, width) {
Engine.instance.height = height;
Engine.instance.width = width;
// TODO: Resize
/**
* if(!Window.resize()) {
* LogError(ErrorCode.WindowResizeFailed);
* }
*/
}
}
Engine.started = false;
Engine.exit = false;
if (!this._window) LogError(ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
}
update() {}
stop() {
this.exit = true;
}
resize(height, width) {
if (this._window) {
this._height = height;
this._width = width;
this._window.resize(this._height, this._width);
} else {
LogError(ErrorCode.EngineWindowUndefined, "The engine's game window is not defined");
}
}
}

class GameWindow {
constructor(title = "", _height = 0, _width = 0) {
this.title = title;
this._height = _height;
this._width = _width;
this.title = title;
this._height = _height;
this._width = _width;
}
get height() {
return this._height;
}
get width() {
return this._width;
}
resize(height, width) {
this._height = height;
this._width = width;
}
}

class DObject {
constructor(id = "") {
this.id = id;
this.id = id;
}
}

class Transform {
constructor(x = 0, y = 0) {
this.x = x;
this.y = y;
this.x = x;
this.y = y;
}
}
class Entity extends DObject {
constructor(id = "", transform = new Transform(), children = new Array(), components = new Array()) {
super(id);
this.transform = transform;
this.children = children;
this.components = components;
this.transform = transform;
this.children = children;
this.components = components;
}
addComponents(...components) {
for (let comp of components) {
this.components.push(comp);
}
}
hasComponent(type) {
let comp = this.components.find(comp => comp.id === type);
if (comp !== undefined) return true;else return false;
}
}

class FlagComponent {
constructor(location = new Transform()) {
this.location = location;
this.id = "FlagComponent";
this.flagnumber = ++FlagComponent.s_flagnumber;
this.location = location;
}
getFlagnumber() {
return this.flagnumber;
}
}
FlagComponent.s_flagnumber = 0;

export { Engine, ErrorCode, LogError, LogInfo };
export { Engine, EngineArguments, GameWindow, DObject, Entity, Transform, EngineConfiguration, ErrorCode, LogError, LogInfo, FlagComponent };

0 comments on commit 7cc6c9a

Please sign in to comment.