Permalink
Find file
b04e6a8 Dec 28, 2011
74 lines (59 sloc) 1.96 KB
<!DOCTYPE HTML>
<html>
<head>
<title>WebCraft</title>
<!-- Character encoding -->
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- Stylesheet -->
<link href="style/main.css" rel="stylesheet" type="text/css">
<!-- Modules -->
<script src="js/glMatrix-1.2.min.js" type="text/javascript"></script>
<script src="js/blocks.js" type="text/javascript"></script>
<script src="js/helpers.js" type="text/javascript"></script>
<script src="js/world.js" type="text/javascript"></script>
<script src="js/render.js" type="text/javascript"></script>
<script src="js/physics.js" type="text/javascript"></script>
<script src="js/player.js" type="text/javascript"></script>
</head>
<body oncontextmenu="return false">
<!-- Render surface -->
<canvas id="renderSurface"></canvas>
<!-- Material selection -->
<table id="materialSelector">
<tr></tr>
</table>
<!-- Initialisation code -->
<script type="text/javascript">
// Create a new flat world
var world = new World( 16, 16, 16 );
world.createFlatWorld( 6 );
// Set up renderer
var render = new Renderer( "renderSurface" );
render.setWorld( world, 8 );
render.setPerspective( 60, 0.01, 200 );
// Create physics simulator
var physics = new Physics();
physics.setWorld( world );
// Create new local player
var player = new Player();
player.setWorld( world );
player.setInputCanvas( "renderSurface" );
player.setMaterialSelector( "materialSelector" );
// Render loop
setInterval( function()
{
var time = new Date().getTime() / 1000.0;
// Simulate physics
physics.simulate();
// Update local player
player.update();
// Build a chunk
render.buildChunks( 1 );
// Draw world
render.setCamera( player.getEyePos().toArray(), player.angles );
render.draw();
while ( new Date().getTime() / 1000 - time < 0.016 );
}, 1 );
</script>
</body>
</html>