-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (77 loc) · 3.13 KB
/
index.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">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript">
window.addEventListener('load', function() {
document.body.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
}, false);
</script>
<title>Index</title>
<!-- Bootstrap -->
<link href="includes/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="includes/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="points" class="container-fluid">
</div>
<div id="field" class="container-fluid">
</div>
<script src="includes/jquery-2.1.4.min.js"></script>
<script src="includes/bootstrap/js/bootstrap.min.js"></script>
<script src="includes/jquery-ui.min.js"></script>
<script src="includes/hammer.js"></script>
<script src="includes/all.js"></script>
<script type="text/javascript">
var snake = new Snake();
var play = setInterval(function () {snake.move()}, 100);
var mc = new Hammer(document.body);
var lastClock = 0;
var iClock = new Array();
var changeClock = new Array();
mc.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
mc.on("swipeleft swiperight swipeup swipedown press", function(ev) {
var newDir = null;
if (ev.type == "press") {
snake.restart();
}
if (snake.parts[0].dir == "cima" || snake.parts[0].dir == "baixo") {
if (ev.type == "swipeleft") {
newDir = "esquerda";
} else if (ev.type == "swiperight") {
newDir = "direita";
}
} else {
if (ev.type == "swipeup") {
newDir = "cima";
} else if (ev.type == "swipedown") {
newDir = "baixo";
}
}
if (newDir != null && newDir != snake.parts[0].dir) {
iClock[++lastClock] = 0;
changeClock[lastClock] = setInterval(function (InsIdC) {
console.log(InsIdC);
snake.changeDir(iClock[InsIdC]++, newDir);
if (iClock[InsIdC] >= snake.size) {
clearInterval(changeClock[InsIdC]);
}
}, 100, lastClock);
}
});
</script>
</body>
</html>