-
Notifications
You must be signed in to change notification settings - Fork 0
/
案例贪吃蛇.html
80 lines (62 loc) · 2.08 KB
/
案例贪吃蛇.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
<style>
.map {
width: 800px;
height: 600px;
background-color: #CCC;
position: relative;
}
</style>
</head>
<body>
<!--画出地图,设置样式-->
<div class="map"></div>
<script src="food.js"></script>
<script src="Snake.js"></script>
<script src="Game.js"></script>
<script>
//初始化游戏对象
var gm = new Game(document.querySelector(".map"));
//初始化游戏---开始游戏
gm.init();
//外部测试代码
// var fd = new Food();
// fd.init(document.querySelector(".map"));
// //创建小蛇
// var snake = new Snake();
// snake.init(document.querySelector(".map"));//先在地图上看到小蛇
//
//
//
// setInterval(function () {
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// }, 150);
// snake.move(fd, document.querySelector(".map"));//走一步
// snake.init(document.querySelector(".map"));//初始化---重新画一条小蛇(先删除之前的小蛇,把现在的小蛇显示出来)
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
//
// snake.move(fd, document.querySelector(".map"));
// snake.init(document.querySelector(".map"));
// fd.init(document.querySelector(".map"));
// fd.init(document.querySelector(".map"));
// fd.init(document.querySelector(".map"));
// fd.init(document.querySelector(".map"));
//console.log(fd.x+"====>"+fd.y);
//console.log(fd.width);
</script>
</body>
</html>