-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e0679e
commit 9c65162
Showing
37 changed files
with
455 additions
and
224 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"use strict"; | ||
var $__js_47_client_47_initialize__, | ||
$__engine_47_Engine__, | ||
$__engine_47_graphics_47_Camera2D__, | ||
$__engine_47_core_47_Actor__, | ||
$__engine_47_processes_47_Script__; | ||
var initialize = ($__js_47_client_47_initialize__ = require("./js/client/initialize"), $__js_47_client_47_initialize__ && $__js_47_client_47_initialize__.__esModule && $__js_47_client_47_initialize__ || {default: $__js_47_client_47_initialize__}).default; | ||
var engine = ($__engine_47_Engine__ = require("engine/Engine"), $__engine_47_Engine__ && $__engine_47_Engine__.__esModule && $__engine_47_Engine__ || {default: $__engine_47_Engine__}).default; | ||
var Camera2D = ($__engine_47_graphics_47_Camera2D__ = require("engine/graphics/Camera2D"), $__engine_47_graphics_47_Camera2D__ && $__engine_47_graphics_47_Camera2D__.__esModule && $__engine_47_graphics_47_Camera2D__ || {default: $__engine_47_graphics_47_Camera2D__}).default; | ||
var Actor = ($__engine_47_core_47_Actor__ = require("engine/core/Actor"), $__engine_47_core_47_Actor__ && $__engine_47_core_47_Actor__.__esModule && $__engine_47_core_47_Actor__ || {default: $__engine_47_core_47_Actor__}).default; | ||
var Script = ($__engine_47_processes_47_Script__ = require("engine/processes/Script"), $__engine_47_processes_47_Script__ && $__engine_47_processes_47_Script__.__esModule && $__engine_47_processes_47_Script__ || {default: $__engine_47_processes_47_Script__}).default; | ||
initialize(); | ||
var main = function() { | ||
engine.camera = new Camera2D(window.innerWidth, window.innerHeight); | ||
var player = engine.factory.create(Actor, "Player"); | ||
engine.scene.addChild(player); | ||
engine.scene.addChild(engine.camera); | ||
engine.scene.getComponent("GameLogic").player = player; | ||
engine.scheduler.addChild(new Script(function() { | ||
engine.camera.render(); | ||
})); | ||
}; | ||
engine.running.then(main); | ||
window.engine = engine; | ||
window.kill = function() { | ||
engine.scheduler.kill(); | ||
}; | ||
window.onbeforeonload = function() { | ||
engine.network.peer.destroy(); | ||
}; | ||
engine.cache.get("assets/world01.json").then(function(world) { | ||
var $__9 = true; | ||
var $__10 = false; | ||
var $__11 = undefined; | ||
try { | ||
for (var $__7 = void 0, | ||
$__6 = (world)[Symbol.iterator](); !($__9 = ($__7 = $__6.next()).done); $__9 = true) { | ||
var actor = $__7.value; | ||
{ | ||
var boulder = engine.factory.create(Actor, "Boulder", actor); | ||
engine.scene.addChild(boulder); | ||
} | ||
} | ||
} catch ($__12) { | ||
$__10 = true; | ||
$__11 = $__12; | ||
} finally { | ||
try { | ||
if (!$__9 && $__6.return != null) { | ||
$__6.return(); | ||
} | ||
} finally { | ||
if ($__10) { | ||
throw $__11; | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
var $__engine_47_core_47_Component__, | ||
$__engine_47_lib_47_gl_45_matrix__; | ||
var Component = ($__engine_47_core_47_Component__ = require("engine/core/Component"), $__engine_47_core_47_Component__ && $__engine_47_core_47_Component__.__esModule && $__engine_47_core_47_Component__ || {default: $__engine_47_core_47_Component__}).default; | ||
var vec2 = ($__engine_47_lib_47_gl_45_matrix__ = require("engine/lib/gl-matrix"), $__engine_47_lib_47_gl_45_matrix__ && $__engine_47_lib_47_gl_45_matrix__.__esModule && $__engine_47_lib_47_gl_45_matrix__ || {default: $__engine_47_lib_47_gl_45_matrix__}).vec2; | ||
var Physics = function($__super) { | ||
function Physics() { | ||
$traceurRuntime.superConstructor(Physics).call(this, "Physics"); | ||
this.velocity = [0, 0]; | ||
} | ||
return ($traceurRuntime.createClass)(Physics, { | ||
update: function(deltaMs) { | ||
var transform = this.actor.getComponent("transform"); | ||
var position = transform.position; | ||
var tmp = vec2.create(); | ||
vec2.add(position, position, vec2.scale(tmp, this.velocity, deltaMs)); | ||
transform.position = position; | ||
}, | ||
setFromJSON: function(json) { | ||
if (!json) | ||
return; | ||
this.velocity = json.velocity; | ||
} | ||
}, {}, $__super); | ||
}(Component); | ||
var $__default = Physics; | ||
Object.defineProperties(module.exports, { | ||
default: {get: function() { | ||
return $__default; | ||
}}, | ||
__esModule: {value: true} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use strict"; | ||
var $__engine_47_core_47_Component__, | ||
$__engine_47_lib_47_gl_45_matrix__, | ||
$__engine_47_Engine__; | ||
var Component = ($__engine_47_core_47_Component__ = require("engine/core/Component"), $__engine_47_core_47_Component__ && $__engine_47_core_47_Component__.__esModule && $__engine_47_core_47_Component__ || {default: $__engine_47_core_47_Component__}).default; | ||
var vec2 = ($__engine_47_lib_47_gl_45_matrix__ = require("engine/lib/gl-matrix"), $__engine_47_lib_47_gl_45_matrix__ && $__engine_47_lib_47_gl_45_matrix__.__esModule && $__engine_47_lib_47_gl_45_matrix__ || {default: $__engine_47_lib_47_gl_45_matrix__}).vec2; | ||
var engine = ($__engine_47_Engine__ = require("engine/Engine"), $__engine_47_Engine__ && $__engine_47_Engine__.__esModule && $__engine_47_Engine__ || {default: $__engine_47_Engine__}).default; | ||
var PlayerController = function($__super) { | ||
function PlayerController(connection) { | ||
var $__5, | ||
$__6, | ||
$__7, | ||
$__8; | ||
$traceurRuntime.superConstructor(PlayerController).call(this, "PlayerController"); | ||
this.keyStates = {}; | ||
this.last = {}; | ||
this.fire = false; | ||
this.mouse = [window.innerWidth / 2, window.innerHeight / 2]; | ||
addEventListener("keydown", ($__5 = this, function(e) { | ||
$__5.keyStates[String.fromCharCode(e.which)] = true; | ||
})); | ||
addEventListener("keyup", ($__6 = this, function(e) { | ||
$__6.keyStates[String.fromCharCode(e.which)] = false; | ||
})); | ||
addEventListener("mousemove", ($__7 = this, function(e) { | ||
$__7.mouse[0] = e.pageX; | ||
$__7.mouse[1] = e.pageY; | ||
})); | ||
addEventListener("mousedown", ($__8 = this, function(e) { | ||
$__8.fire = true; | ||
})); | ||
} | ||
return ($traceurRuntime.createClass)(PlayerController, {update: function(deltaMs) { | ||
var events = {}; | ||
var keyStates = this.keyStates; | ||
var last = this.last; | ||
for (var key in keyStates) { | ||
if (keyStates[key] !== last[key]) { | ||
if (key == "W") { | ||
events["SET_MOVING_UP"] = keyStates[key]; | ||
} | ||
if (key == "A") { | ||
events["SET_MOVING_LEFT"] = keyStates[key]; | ||
} | ||
if (key == "S") { | ||
events["SET_MOVING_DOWN"] = keyStates[key]; | ||
} | ||
if (key == "D") { | ||
events["SET_MOVING_RIGHT"] = keyStates[key]; | ||
} | ||
} | ||
} | ||
if (Object.keys(events).length) { | ||
engine.emit("PlayerController:events", events); | ||
this.last = JSON.parse(JSON.stringify(this.keyStates)); | ||
} | ||
engine.emit("PlayerController:mouse", engine.camera.mouseToWorld(this.mouse)); | ||
if (this.fire) { | ||
this.fire = false; | ||
engine.emit("PlayerController:events", {FIRE: true}); | ||
} | ||
}}, {}, $__super); | ||
}(Component); | ||
var $__default = PlayerController; | ||
Object.defineProperties(module.exports, { | ||
default: {get: function() { | ||
return $__default; | ||
}}, | ||
__esModule: {value: true} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use strict"; | ||
var $__engine_47_Initialize__, | ||
$__engine_47_components_47_Transform2D__, | ||
$___46__46__47_shared_47_PlayerLogic__, | ||
$__PlayerController__, | ||
$___46__46__47_shared_47_GameLogic__, | ||
$__engine_47_components_47_Sprite__, | ||
$__Physics__, | ||
$__engine_47_components_47_Lifetime__, | ||
$___46__46__47_shared_47_constants__; | ||
var Initialize = ($__engine_47_Initialize__ = require("engine/Initialize"), $__engine_47_Initialize__ && $__engine_47_Initialize__.__esModule && $__engine_47_Initialize__ || {default: $__engine_47_Initialize__}).default; | ||
var Transform2D = ($__engine_47_components_47_Transform2D__ = require("engine/components/Transform2D"), $__engine_47_components_47_Transform2D__ && $__engine_47_components_47_Transform2D__.__esModule && $__engine_47_components_47_Transform2D__ || {default: $__engine_47_components_47_Transform2D__}).default; | ||
var PlayerLogic = ($___46__46__47_shared_47_PlayerLogic__ = require("../shared/PlayerLogic"), $___46__46__47_shared_47_PlayerLogic__ && $___46__46__47_shared_47_PlayerLogic__.__esModule && $___46__46__47_shared_47_PlayerLogic__ || {default: $___46__46__47_shared_47_PlayerLogic__}).default; | ||
var PlayerController = ($__PlayerController__ = require("./PlayerController"), $__PlayerController__ && $__PlayerController__.__esModule && $__PlayerController__ || {default: $__PlayerController__}).default; | ||
var GameLogic = ($___46__46__47_shared_47_GameLogic__ = require("../shared/GameLogic"), $___46__46__47_shared_47_GameLogic__ && $___46__46__47_shared_47_GameLogic__.__esModule && $___46__46__47_shared_47_GameLogic__ || {default: $___46__46__47_shared_47_GameLogic__}).default; | ||
var Sprite = ($__engine_47_components_47_Sprite__ = require("engine/components/Sprite"), $__engine_47_components_47_Sprite__ && $__engine_47_components_47_Sprite__.__esModule && $__engine_47_components_47_Sprite__ || {default: $__engine_47_components_47_Sprite__}).default; | ||
var Physics = ($__Physics__ = require("./Physics"), $__Physics__ && $__Physics__.__esModule && $__Physics__ || {default: $__Physics__}).default; | ||
var Lifetime = ($__engine_47_components_47_Lifetime__ = require("engine/components/Lifetime"), $__engine_47_components_47_Lifetime__ && $__engine_47_components_47_Lifetime__.__esModule && $__engine_47_components_47_Lifetime__ || {default: $__engine_47_components_47_Lifetime__}).default; | ||
var PEERJS_API_KEY = ($___46__46__47_shared_47_constants__ = require("../shared/constants"), $___46__46__47_shared_47_constants__ && $___46__46__47_shared_47_constants__.__esModule && $___46__46__47_shared_47_constants__ || {default: $___46__46__47_shared_47_constants__}).PEERJS_API_KEY; | ||
var $__default = function() { | ||
Initialize({ | ||
scene: { | ||
id: 1, | ||
type: "Scene" | ||
}, | ||
scheduler: {deltaMs: 17}, | ||
factory: { | ||
skeletons: { | ||
"assets/entities/client/player.json": "Player", | ||
"assets/entities/client/scene.json": "Scene", | ||
"assets/entities/client/particle.json": "Particle", | ||
"assets/entities/client/boulder.json": "Boulder" | ||
}, | ||
components: { | ||
"Transform2D": Transform2D, | ||
"PlayerLogic": PlayerLogic, | ||
"PlayerController": PlayerController, | ||
"GameLogic": GameLogic, | ||
"Sprite": Sprite, | ||
"Physics": Physics, | ||
"Lifetime": Lifetime | ||
} | ||
} | ||
}); | ||
}; | ||
Object.defineProperties(module.exports, { | ||
default: {get: function() { | ||
return $__default; | ||
}}, | ||
__esModule: {value: true} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use strict"; | ||
var $__engine_47_Initialize__, | ||
$__engine_47_components_47_Transform2D__, | ||
$__engine_47_components_47_Synchronizer__, | ||
$___46__46__47_shared_47_constants__, | ||
$___46__46__47_shared_47_PlayerLogic__; | ||
var Initialize = ($__engine_47_Initialize__ = require("engine/Initialize"), $__engine_47_Initialize__ && $__engine_47_Initialize__.__esModule && $__engine_47_Initialize__ || {default: $__engine_47_Initialize__}).default; | ||
var Transform2D = ($__engine_47_components_47_Transform2D__ = require("engine/components/Transform2D"), $__engine_47_components_47_Transform2D__ && $__engine_47_components_47_Transform2D__.__esModule && $__engine_47_components_47_Transform2D__ || {default: $__engine_47_components_47_Transform2D__}).default; | ||
var Synchronizer = ($__engine_47_components_47_Synchronizer__ = require("engine/components/Synchronizer"), $__engine_47_components_47_Synchronizer__ && $__engine_47_components_47_Synchronizer__.__esModule && $__engine_47_components_47_Synchronizer__ || {default: $__engine_47_components_47_Synchronizer__}).default; | ||
var PEERJS_API_KEY = ($___46__46__47_shared_47_constants__ = require("../shared/constants"), $___46__46__47_shared_47_constants__ && $___46__46__47_shared_47_constants__.__esModule && $___46__46__47_shared_47_constants__ || {default: $___46__46__47_shared_47_constants__}).PEERJS_API_KEY; | ||
var PlayerLogic = ($___46__46__47_shared_47_PlayerLogic__ = require("../shared/PlayerLogic"), $___46__46__47_shared_47_PlayerLogic__ && $___46__46__47_shared_47_PlayerLogic__.__esModule && $___46__46__47_shared_47_PlayerLogic__ || {default: $___46__46__47_shared_47_PlayerLogic__}).default; | ||
var $__default = function() { | ||
Initialize({ | ||
network: { | ||
name: "game", | ||
key: PEERJS_API_KEY | ||
}, | ||
scene: { | ||
id: 1, | ||
type: "Scene" | ||
}, | ||
scheduler: {deltaMs: 33}, | ||
factory: { | ||
skeletons: { | ||
"assets/entities/server/player.json": "Player", | ||
"assets/entities/server/scene.json": "Scene" | ||
}, | ||
components: { | ||
"Transform2D": Transform2D, | ||
"Synchronizer": Synchronizer, | ||
"PlayerLogic": PlayerLogic | ||
} | ||
} | ||
}); | ||
}; | ||
Object.defineProperties(module.exports, { | ||
default: {get: function() { | ||
return $__default; | ||
}}, | ||
__esModule: {value: true} | ||
}); |
Oops, something went wrong.