Created
April 3, 2015 14:32
-
-
Save CharlotteGore/59b303793983ac39ac5c to your computer and use it in GitHub Desktop.
Hexr Engine
This file contains hidden or 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
// load the webgl world.. | |
var world = require('./world')(document.getElementById('screen')); | |
// load the level data (universe.json) into the universe module.. | |
var universe = require('./mapper.js')(require('./universe.json')); | |
// initialise a map.. | |
var level = universe.initialiseLevel('1-1'); | |
// add the parallax meshes to the scene... | |
each(level.getParallaxMeshes(), function (mesh){ | |
// Hack! Ah ah! It'll save every one of us! | |
mesh.scale.set(2,2,2); | |
mesh.position.z = -50; | |
mesh.material.color = new THREE.Color(0x999999) | |
world.scene.add(mesh); | |
}); | |
// add the normal meshes to the scene... | |
each(level.getTileMeshes(), function (mesh){ | |
//mesh.material = new THREE.MeshBasicMaterial({ color : 0xffffff}) | |
world.scene.add(mesh); | |
}); | |
// create a game loop callback.. | |
var fn = (function gameTick(worldTime){ | |
// make the camera pan back and forth.. | |
var progress = -8 + Math.abs(-1 + ((worldTime.now % 4 / 4) * 2)) * 16; | |
world.cameraman.setPosition({ x : progress, y : 0, z : 50}); world.cameraman.lookAt({ x : progress,y : 0, z : 50}) | |
}).bind(world); | |
// register our game loop callback with the webgl world. | |
world.on('tick', fn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment