Created
February 8, 2013 22:32
-
-
Save snagy/4742486 to your computer and use it in GitHub Desktop.
voxel.js game
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
var createGame = require('voxel-engine') | |
function sphereWorld(x, y, z) { | |
// return the index of the material you want to show up | |
// 0 is air | |
if (x*x + y*y + z*z > 15*15) return 0 | |
return 3 | |
} | |
var game = createGame({ | |
generate: sphereWorld, | |
startingPosition: [0, 1000, 0], // x, y, z | |
materials: [['grass', 'dirt', 'grass_dirt'], 'brick', 'dirt', 'obsidian', 'bedrock'] | |
}) | |
// rotate camera to look straight down | |
game.controls.pitchObject.rotation.x = -1.5 | |
var container = document.body | |
game.appendTo(container) | |
// have the game take over your mouse pointer when you click on it | |
game.setupPointerLock(container) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment