-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetris.html
153 lines (119 loc) · 4.01 KB
/
tetris.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
<link rel="manifest" href="site.webmanifest">
<link rel="apple-touch-icon" href="icon.png">
<!-- Place favicon.ico in the root directory -->
<!-- <link rel="stylesheet" href="css/normalize.css"> -->
<link rel="stylesheet" href="css/main.css">
<style>
.sg-wrap {
position: relative;
margin: auto;
width: 60%;
height: 0;
padding-bottom: 60%;
}
.controls {
margin: auto;
}
#app {
text-align: center;
}
</style>
<script src="https://hammerjs.github.io/dist/hammer.min.js"></script>
<script src="js/tetris/bundle.js"></script>
</head>
<body>
<!--[if lte IE 9]>
<p class="browserupgrade">You are using an <strong>otudated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
<![endif]-->
<!-- Add your site or application content here -->
<section>
<a href="https://github.com/eguneys/tetris"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<a class="navback" href="games.html"> See other games </a>
<h1>Play Tetris</h1>
<section>
<div id="app"></div>
</section>
<div class="social">
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet?text=Play Tetris!"
data-size="large">
Tweet</a>
</div>
<div class="information">
</div>
</section>
<script>window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}(document, "script", "twitter-wjs"));</script>
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script>
WebFont.load({
google: {
families: ['Roboto']
},
active:e=>{
console.log("font loaded!");
init();
}
});
function init() {
const api = Tetris(document.getElementById('app'), {
events: {
loaded: onLoad
}
});
function onLoad() {
var hammertime = new Hammer(document.body, {});
hammertime.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
hammertime.on('swipe', function(ev) {
switch (ev.direction) {
case 2:
api.move('left');
break;
case 4:
api.move('right');
break;
case 8:
api.move('up');
break;
case 16:
api.move('down');
break;
}
})
}
}
</script>
<!-- <script src="js/vendor/modernizr-{{MODERNIZR_VERSION}}.min.js"></script> -->
<!-- <script src="https://code.jquery.com/jquery-{{JQUERY_VERSION}}.min.js" integrity="{{JQUERY_SRI_HASH}}" crossorigin="anonymous"></script> -->
<!-- <script>window.jQuery || document.write('<script src="js/vendor/jquery-{{JQUERY_VERSION}}.min.js"><\/script>')</script> -->
<!-- <script src="js/plugins.js"></script> -->
<!-- <script src="js/main.js"></script> -->
<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-42906606-9', 'auto'); ga('send', 'pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
</body>
</html>