summaryrefslogtreecommitdiff
path: root/gui.js
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-01-25 19:09:55 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-01-25 19:09:55 +0100
commitaa801f4c58398343f1ba6a7cae3c797c68fd7d30 (patch)
tree82c52f24a75c8713a3e73777b9970e594dc3a185 /gui.js
parent7c567632f21d37509b656cf820ffbbc08e3d98f2 (diff)
downloadsnap-byow-aa801f4c58398343f1ba6a7cae3c797c68fd7d30.tar.gz
snap-byow-aa801f4c58398343f1ba6a7cae3c797c68fd7d30.zip
clean up the code
Diffstat (limited to 'gui.js')
-rw-r--r--gui.js65
1 files changed, 4 insertions, 61 deletions
diff --git a/gui.js b/gui.js
index 569e580..e756500 100644
--- a/gui.js
+++ b/gui.js
@@ -2954,60 +2954,7 @@ IDE_Morph.prototype.openProjectString = function (str) {
IDE_Morph.prototype.rawOpenProjectString = function (str) {
// BYOW changes
- // TODO too messy, split things up function
- function generator(x, y, z) {
- return y === 1 ? 1 : 0;
- }
- function defaultSetup(game, avatar) {
- var makeFly = fly(game);
- var target = game.controls.target();
- game.flyer = makeFly(target);
-
- // highlight blocks when you look at them, hold <Ctrl> for block placement
- var blockPosPlace, blockPosErase;
- var hl = game.highlighter = highlight(game, { color: 0xff0000 });
- hl.on('highlight', function (voxelPos) { blockPosErase = voxelPos; });
- hl.on('remove', function (voxelPos) { blockPosErase = null; });
- hl.on('highlight-adjacent', function (voxelPos) { blockPosPlace = voxelPos; });
- hl.on('remove-adjacent', function (voxelPos) { blockPosPlace = null; });
-
- // block interaction stuff, uses highlight data
- var currentMaterial = 1;
-
- game.on('fire', function (target, state) {
- var position = blockPosPlace;
- if (position) {
- game.createBlock(position, currentMaterial);
- }
- else {
- position = blockPosErase;
- if (position) game.setBlock(position, 0);
- }
- });
-
- game.on('tick', function() {
- walk.render(target.playerSkin);
- var vx = Math.abs(target.velocity.x);
- var vz = Math.abs(target.velocity.z);
- if (vx > 0.001 || vz > 0.001) walk.stopWalking();
- else walk.startWalking();
- });
- }
-
- window.game = window.gameWorld = undefined;
-
- var options = {
- generate: generator,
- chunkDistance: 2
- };
- window.game = createGame(options);
- window.gameWorld = document.createElement('div');
- window.game.appendTo(window.gameWorld);
- window.createPlayer = window.player(window.game);
- window.gamePlayer = createPlayer('greg.png');
- window.gamePlayer.possess();
- window.gamePlayer.yaw.position.set(2, 14, 4);
- defaultSetup(window.game, window.gamePlayer);
+ window.initGame();
this.toggleAppMode(false);
this.spriteBar.tabBar.tabTo('scripts');
@@ -3427,17 +3374,13 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
}
this.setExtent(this.world().extent()); // resume trackChanges
- /* BYOW changes */
+ // BYOW changes
if (this.isAppMode) {
document.body.appendChild(window.gameWorld);
document.getElementById('world').style.display = 'none';
} else {
- for (j = 0; j < document.body.children.length; j++) {
- // TODO refactor
- if (document.body.children[j] == window.gameWorld) {
- document.body.removeChild(window.gameWorld);
- break;
- }
+ if (document.body.contains(window.gameWorld)) {
+ document.body.removeChild(window.gameWorld);
}
document.getElementById('world').style.display = null;
}