写的一段js贪吃蛇代码,希望大家喜欢

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Snakey</title>
<!--<base href="http://jquery-snakey.googlecode.com/svn/trunk/" />-->
<link rel="stylesheet" type="text/css"media="screen" href="css/jq.css" />
<link rel="stylesheet" type="text/css"media="screen" href="css/tabs.css" />
<link rel="stylesheet" type="text/css"media="screen" href="css/snake.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<!--<script type="text/javascript" src="js/jquery.js"></script>-->
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.snake.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<div>
<a id="logo" href="http://jquery.com"title="Powered By jQuery"></a>
</div>
<h1 id="banner">
jQuery Snakey
</h1>
<div id="main">
<ul id="nav" class="anchors">
<li><a href="#overview">Overview</a></li>
</ul>
<div id="overview" class="tabContent">
<div id="snake-col-info" class="col-r">
<div id="marginLeft">
<h2><a href="#instructions"class="accordian open">Instructions</a></h2>
<div id="instructions">
<p>
Use the keyboard arrow keys to control the snake. Eat the specified amount of cherries to advance to the next level,
without slithering into yourself or a wall. The speed and length of the snake will increase with every cherry eaten.
The game ends when you have used up all your lives, or when you finish all levels. Have fun!
</p>
</div>
<h2><a href="#shortcut-keys"class="accordian open">Shortcut Keys</a></h2>
<div id="shortcut-keys">
<ul>
<li>P : Pause/Resume Game</li>
<li>N : New Game</li>
<li>G : Toggle Grid</li>
</ul>
</div>
<h2><a href="#high-scores"class="accordian">High Scores</a></h2>
<div id="high-scores" class="scores hidden">
(coming soon..)
<!--
<span class="head">
<span class="col1">
Pos.
</span>
<span class="col2">
Score
</span>
<span class="col3">
Name
</span>&nbsp;
</span>
-->
</div>
<h2><a href="#bugs"class="accordian">Bugs &amp; Todo</a></h2>
<div id="bugs" class="hidden">
<ul>
<li class="strike">TODO: Make snake grow in length</li>
<li class="strike">TODO: Introduce levels</li>
<li class="strike">TODO: Introduce wall obstacles</li>
<li class="strike">TODO: Game over when snake slithers into itself</li>
<li class="strike">BUG: new game, need to reset segment object using initial values</li>
<li class="strike">BUG: cherries cannot be positioned under snake or wall segments</li>
<li>BUG: snake needs to grow from tail and not from head</li>
<li class="strike">TODO: add multiple wall obstacles</li>
<li>TODO: Track/store high scores</li>
</ul>
</div>
<h2><a href="#source"class="accordian">Source</a></h2>
<div id="source" class="hidden"style="margin-top:0px">
<ul>
<li>
<a href="http://jquery-snakey.googlecode.com/svn/trunk/js/jquery.snake.js">jquery.snake.js</a>
(Uncompressed &amp; commented)
</li>
</ul>
</div>
<h2><a href="#info"class="accordian">Info/Contact</a></h2>
<div id="info" class="hidden">
<ul>
<li>
<p>Tested on all major browsers:</p>
<p class="browser-icons">
<a class="firefox" title="Firefox 2 &amp; 3"href="http://www.mozilla.com/firefox/">&nbsp;</a>
<a class="explorer" title="Explorer 6, 7 &amp; 8"href="http://www.microsoft.com/windows/products/winfamily/ie/">&nbsp;</a>
<a class="safari" title="Safari 3"href="http://www.apple.com/safari/">&nbsp;</a>
<a class="opera" title="Opera 9"href="http://www.opera.com">&nbsp;</a>
<a class="chrome" title="Chrome"href="http://www.google.com/chrome">&nbsp;</a>
</p>&nbsp;
</li>
<li>
<p>
Please use the <a href="http://code.google.com/p/jquery-snakey/issues/list">issue tracker</a> to log any bugs. Any feedback can be sent to:
</p>
<p>
<img src="img/gmail.png"alt="my email" />
</p>
</li>
<li>
<p>
This isn't a particularly large project, but it was fun making it! <br/>
You can check out the project, including all source code &amp;
repository at <a href="http://jquery-snakey.googlecode.com">jquery-snakey.googlecode.com</a>
</p>
</li>
</ul>
</div>
</div>
</div>
<div id="snake-col-map" class="col-l">
<!--
<noscript class="error">
You need javascript enabled on your browser to be able to play this game.
</noscript>
-->
<div id="map1">
<span id="map-msg">
<!-- click to give focus to the document -->
<a href="#start"id="start-game">
<img src="img/snake/start_game.jpg"alt="Start Game!" />
</a>
</span>
</div>
<div id="stats">
<span class="right">Eaten:
<span id="stats-eaten">0</span> /
<span id="stats-totcherries">0</span>
</span>
Level: <span id="stats-level">0</span> |
Lives: <span id="stats-lives">0</span> |
Score: <span id="stats-score">0</span>
</div>
</div>
</div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值