-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.html
More file actions
256 lines (192 loc) · 7.49 KB
/
Copy pathgame.html
File metadata and controls
256 lines (192 loc) · 7.49 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="game.css">
<title>TETRIS-JS</title>
<script src="https://kit.fontawesome.com/dc653ad1e0.js" crossorigin="anonymous"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap');
</style>
</style>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity= "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous">
</script>
</head>
<body>
<audio id="background-music" src="tetris-sounds/original-tetris-theme.mp3"></audio>
<audio id="move-sound" src="tetris-sounds/movement-sound-tetris.mp3"></audio>
<audio id="line-clear-sound" src="tetris-sounds/clear-lines-sound-tetris.mp3"></audio>
<audio id="game-over-sound" src="tetris-sounds/game-over-tetris.mp3"></audio>
<div class="game">
<div class="canvas-container">
<!-- width should total to 400 -->
<div id="pause-screen" class="hidden">
<p>
PAUSED
</p>
</div>
<div id="count-down" class="hidden">
<p>
3
</p>
</div>
<div id="load-page" class="hidden">
<p>
LOADING...
</p>
</div>
<div id="start-page" >
<!-- <div class="t-container">
</div> -->
<p>
TETRIS
</p>
<!-- <div class="t2-container">
</div> -->
<div id="start-buttons">
<button id="play">
PLAY
</button>
<button id="reset-score">
RESET SCORE
</button>
</div>
</div>
<div id="game-over" class="hidden">
<p>
GAME OVER
</p>
<div id="decisions" style="display: inline;">
<button id="Retry">
RETRY
</button>
<button id="Quit">
QUIT
</button>
</div>
</div>
<canvas id="main-canvas" class ="main-canvas" width="300" height="500">
Your browser does not support the HTML5 canvas tag.
</canvas>
<!-- if no work make width and height same as main -->
<canvas id="piece-canvas" class="piece-canvas" width="260" height="480" >
Your browser does not support the HTML5 canvas tag.
</canvas>
<canvas id="grid-canvas" class="grid-canvas" width="300" height="500">
Your browser does not support the HTML5 canvas tag.
</canvas>
</div>
<div class="right-side">
<div class="score">
<!-- score will be purely text controlled by js -->
<div>
<p style="display: inline;">Score: </p>
<p id="score" style="display: inline;">0 </p>
</div>
<div>
<p style="display: inline;"> Hi-Score: </p>
<p id="hi-score" style="display: inline;"> 0 </p>
</div>
<div>
<p style="display: inline;"> Lines: </p>
<p id="lines" style="display: inline;"> 0 </p>
</div>
<div>
<p style="display: inline;"> Level: </p>
<p id="Level" style="display: inline;"> 1 </p>
</div>
<p> Next: </p>
</div>
<canvas id="piece-preview" width="100" height="100" >
Your browser does not support the HTML5 canvas tag.
</canvas>
<div class="score">
<!-- to the right of pause -->
<div style="display: inline;" class="audio-controls">
<div>
<i class="fa-solid"> </i>
<label class="switch" id="music-control">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
<div>
<i class="fa-solid">  </i>
<label class="switch" id="sound-control">
<input type="checkbox">
<span class="slider round"></span>
</label>
<!-- <i class="fa-solid" id="sound-control1"> </i> -->
<!-- <i class="fa-solid fa-toggle-off" id="sound-control1"></i>
<i class="fa-solid" id="sound-control2" style="display:none;"> </i> -->
</div>
<!-- toggle on  -->
</div>
<button id="pause">PAUSE</button>
<!-- <button id="Retry" >Retry</button>
<button id="Quit">QUIT</button> -->
</div>
</div>
</div>
<section>
<h2>Vanilla Javascript Tetris Game (FOCUS: Full-Stack) </h2>
<h3> SUMMARY OF CONCEPTS:</h3>
<h4>FRONTEND:
</h4>
<ul>
<li>
Use of flex box for display harmony uniform accross
different web devices
</li>
<li>
Use of CSS shapes and attributes to create responsive toggle buttons
</li>
<li>
Use of HTML5 Canvas element to show visual changes and mimic movement
</li>
</ul>
<h4> BACKEND:
</h4>
<ul>
<li>
Use of Array Data Structure to keep track of changes
drawn unto the screen
</li>
<li>
Use of requestanimationframe to reduce load on CPU resources</li>
<li>
Use of async functions and promises to ensure certain events follow
the designed game order
</li>
</ul>
<h4>DATABASE MANAGEMENT:
</h4>
<ul>
<li>
Initially made use of local storage API call
</li>
<li>
Finally made use of Mongo DB Data API to ensure persistence of
high-score and reset score after subsequent browser refresh
</li>
</ul>
<h4>TESTING METHODS:
</h4>
<ul>
<li>
Automated Unit testing for expected behaviour using Jasmine framework
</li>
<li>
Testing edge cases and expected behaviour by playing the game and having others
play as well
</li>
</ul>
</section>
<!-- javascript code to control! -->
<script src="src/game.js">
</script>
</body>
</html>