diff options
Diffstat (limited to 'gui.js')
| -rw-r--r-- | gui.js | 65 |
1 files changed, 4 insertions, 61 deletions
@@ -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; } |
