-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
121 lines (116 loc) · 3.32 KB
/
Copy pathindex.html
File metadata and controls
121 lines (116 loc) · 3.32 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!doctype html>
<html>
<head>
<title>jQuery Snake</title>
<!-- jQuery Libraries to reduce my coding time a little bit -->
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/jSnake.js"></script>
<script type="text/javascript">
$(document).ready(function(){
/* Game Starter */
$("#GridContainer").Snake({
grid:[25,25],
score:true,
controls: "auto"
});
// Open-Close Control Tab
$("#tab .tabControl").on("click",function(){
var $el = $("#tab");
if($el.hasClass("closed")){
$el.removeClass("closed");
}else{
$el.addClass("closed");
}
});
/* jQuery Controls */
// Grid size
$("#UpdateGrid").on("click",function(){
var valX = parseInt($("#gridX").val()),
valY = parseInt($("#gridY").val());
if(valX>0 && valY>0){
$("#GridContainer").Snake([valX,valY]);
}
});
// Speed
$("#speed").on("change",function(){
$("#GridContainer").Snake(parseInt($("#speed").val()));
});
// Toogle Walls
$("#enableWalls").on("click",function(){
if(this.checked){
$("#GridContainer").Snake("walls");
}else{
$("#GridContainer").Snake("noWalls");
}
});
// Add Enemy Snake
$("#btnAddEnemy").on("click",function(){
$("#GridContainer").Snake("newEnemy");
});
// Add Killer Snake
$("#btnAddKiller").on("click",function(){
$("#GridContainer").Snake("newKiller");
});
// Start / Stop button
$("#btnStartStop").on("click",function(){
$("#GridContainer").Snake("toggle");
updateBtn();
});
// Reset button
$("#btnReset").on("click",function(){
$("#GridContainer").Snake("reset");
updateBtn();
});
updateBtn = function(){
var newVal = ($("#GridContainer").data("Snake").vals.start) ? "Stop" : "Start";
$("#btnStartStop").val(newVal);
}
})
</script>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<h1>Snake</h1>
<div id="GridContainer"></div>
<form id="tab">
<div>
<h2 class="title">Change grid size:</h2>
<span class="legend">
Min-Size: 5 cells<br />
Max-Size: 150 cells
</span>
<input type="text" id="gridX" /> x
<input type="text" id="gridY" />
<input type="button" id="UpdateGrid" class="button" value="update" />
</div>
<div>
<h2 class="title">Change speed:</h2>
<select id="speed">
<option value="1000">Very Slow</option>
<option value="500">Slow</option>
<option value="250" selected="selected">Normal</option>
<option value="125">Fast</option>
<option value="60">UltraFast</option>
<select>
</div>
<div>
<h2 class="title">Walls:</h2>
<label>
<input type="checkbox" id="enableWalls" />
Active
<label>
</div>
<div>
<h2 class="title">Add Enemies:</h2>
<input type="button" id="btnAddEnemy" class="button" value="Snake">
<input type="button" id="btnAddKiller" class="button" value="Killer Snake">
</div>
<div>
<h2 class="title">Controls:</h2>
<input type="button" id="btnStartStop" class="button" value="Pause">
<input type="button" id="btnReset" class="button" value="Reset">
</div>
<div class="tabControl">Options</div>
</form>
</body>
</html>