3 Star 0 Fork 0

mirrors_Overv/WebCraft

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
singleplayer.html 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
Alexander Overvoorde 提交于 2011-12-28 18:17 . Adds multiplayer base code.
<!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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_Overv/WebCraft.git
git@gitee.com:mirrors_Overv/WebCraft.git
mirrors_Overv
WebCraft
WebCraft
master

搜索帮助