javascript实现简单的贪吃蛇游戏,功能很简单,代码也很实用,就不多废话了,小伙伴们参考注释吧。
<html>
<head>
<meta http-equiv='content-type' content='text/html;charset=utf-8'>
<title>贪吃蛇</title>
[removed]
var map; //地图
var snake; //蛇
var food; //食物
var timer; //定时器
var initSpeed=200; //初始定时器时间间隔(毫秒),间接代表蛇