我在一个网站上找到了html5游戏(一个有电脑的玩家)并将其转换为2个玩家。这是我的汇总代码:
<html>
<head><title></title></head>
<body onload="javascript: paintBoard();">
<canvas width="500" height ="500" id="board" onclick="javascript: clickHandler(event);"
</canvas>
<script>
.... //my html5 game logic is written in here that works correctly
</script>
</script>
</body>
</html>
当我运行浏览器看到我的(这个文件名是tictactoe.html)代码在浏览器中没有问题看到游戏,但当我把这个代码放到另一个有模板的页面时我看不到任何东西。该页面名称是play.php,像这样:
<!DOCTYPE HTML>
<html>
<head>
<title>world Game Center </title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!-- stylesheets -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/light.css" rel="stylesheet" type="text/css" />
<!-- modernizr enables HTML5 elements and feature detects -->
<script type="text/javascript" src="js/modernizr-1.5.min.js"></script>
<script type="text/javascript" src="js/tictactoe.js"></script> //this is the game logic that i suggest above.
</head>
<body >
<div id="main">
<!-- begin header -->
<header>
<nav>
<ul class="sf-menu" id="nav">
<li><a href="index.php">home</a></li>
</ul>
</nav>
<div id="logo"><h1>game center <a href="#">online</a>world</h1></div>
</header>
<!-- end header -->
<!-- begin content -->
<div id="site_content">
<div id="left_content">
<center>
<form id="name_form">
<h1>chat</h1>
<!-- <input type=text id="name_input"
style="width: 200px; margin: 2px" disabled>
<input type="submit" id="connect_button" value="Connect"
style="width: 70px; margin: 2px" disabled>
</form>
-->
<textarea id="chat_box" readonly="readonly"
style="width: 400px; height: 400px;
margin: 2px; resize: none"></textarea>
</textarea>
<form id="message_form">
<input type=text id="message_input"
style="width: 220px; height: 18px; margin: 2px" disabled>
<input type="submit" id="send_button" value="Send"
style="width: 60px; margin: 2px" disabled>
</form>
</center>
</div>
<div id="right_content">
<canvas width="500" height ="500" id="board" onclick="javascript: clickHandler(event);"></canvas>
</div>
</div>
<!-- end content -->
</div>
<!-- javascript at the bottom for fast page loading -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easing-sooper.js"></script>
<script type="text/javascript" src="js/jquery.sooperfish.js"></script>
<!-- initialise sooperfish menu -->
<script type="text/javascript">
$(document).ready(function() {
$('ul.sf-menu').sooperfish();
});
</script>