You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+58-9
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,15 @@
1
1
# TETRIS ALMOST FROM SCRATCH
2
-
This is an attempt of making the game [Tetris](https://en.wikipedia.org/wiki/Tetris) using modern programming languages. The idea is to time the development and track the progress and the time it took to get in each stage in this document. If possible I want to finish this project in under 12 h.
2
+
This is an attempt of making the game [Tetris](https://en.wikipedia.org/wiki/Tetris) using modern programming languages. The idea is to time the development and track the progress and the time it took to get in each stage in this document. If possible I want to finish this project in under 24 h.
3
3
4
4
Tetris is the first software to be exported from the USSR to the US and became and not only became one of the most famous computer games, it has been released for nearly every videogame console and computer operating system.
5
5
6
-
For this project, I'll be using the engine built for the [tetris-almost-from-scratch](https://github.com/luxedo/tetris-almost-from-scratch). I'll try to improve it and try to draw only characters on screen. The idea is to simulate the original game and also show an improved view using the same engine.
6
+
For this project, I'll be using the engine built for the [asteroids-almost-from-scratch](https://github.com/luxedo/asteroids-almost-from-scratch). I'll try to improve it and try to draw only characters on screen. The idea is to simulate the original game and also show an improved view using the same engine.
The game is based in html5/canvas, CSS and ES6 javascript.
10
11
11
-
#### Check it out [here](https://luxedo.github.io/tetris-almost-from-scratch/)
12
+
#### Check it out [here](https://tetris-almost-from-scratch.firebaseapp.com/)
12
13
13
14
## Goals
14
15
*~~Add `LICENSE.md` and `README.md`~~
@@ -28,8 +29,7 @@ The game is based in html5/canvas, CSS and ES6 javascript.
28
29
*~~Create "next piece" display~~
29
30
*~~Create Menu screen and Credits screen~~
30
31
*~~Create high-scores~~
31
-
* Add sounds
32
-
* Improve webpage
32
+
*~~Add sounds~~
33
33
* Fix playtesters requests
34
34
* Finished!
35
35
@@ -160,9 +160,11 @@ were above that line.
160
160
## 13:00 - Create levels/scoring
161
161
The scoring system I used was the [Original Nintendo Scoring System](http://tetris.wikia.com/wiki/Scoring). In summary it is a table of a base according to the number of broken lines times the current level+1.
162
162
163
-
For the levels, I chose to increase it for every 10 broken lines, as in the NES version.
163
+
For the levels, I chose to increase it for every 10 broken lines, as in the NES
164
+
version.
164
165
165
-
To show the socores (`СЧЕТ`) and the level (`УРОВЕНЬ`) I decided to use the original words in russian.
166
+
To show the socores (`СЧЕТ`) and the level (`УРОВЕНЬ`) I decided to use the
167
+
original words in russian.
166
168
167
169

168
170
@@ -187,5 +189,52 @@ the background and border for those screens to inherit.
187
189
188
190

189
191
190
-
## 19:00 - Create high-scores
191
-
I implemented the High Scores for the [Asteroids](https://luxedo.github.io/asteroids-almost-from-scratch/) project, so I just had to copy that and do some refactoring.
192
+
## 22:30 - Create high-scores
193
+
I implemented the `High Scores` for the [Asteroids](https://luxedo.github.io/asteroids-almost-from-scratch/) game and deployed on [Heroku](https://www.heroku.com/).
194
+
I'ts quite easy to work with them but unfortunately I'm out of [dynos](https://www.heroku.com/dynos).
195
+
Because of that I had to look for another host.
196
+
197
+
I chose to host at [Firebase](https://firebase.google.com) because their free tier
198
+
is quite nice. This game is not built for mobile but I intend to port it in the
199
+
future. It was also a chance to learn how to use the `Firebases`'s services and I
200
+
really enjoyed the experience. It took around 5 hours of studying and messing around
201
+
and 30 minutes of coding to make the `High Scores` work.
202
+
203
+
In the end, `Firebase` takes care of a lot of complexity when setting up a
204
+
database which is very nice. In the end, I just had to use their javascript
205
+
client to read and write in the database and hopefully the security part is
206
+
handled by them. I still don't understand how [Progressive Web Apps](https://developers.google.com/web/progressive-web-apps/)
207
+
are meant to be built, but I know that this app is working.
208
+
209
+

210
+
211
+
Because of the Firebase studies, I'm going to extend the project's deadline to
212
+
26 hours.
213
+
214
+
## 26:00 - Add sounds
215
+
Phew this took more time than I imagined. I just blew my newest deadline.
216
+
217
+
I had code from the previous games to play sounds, but I decided to
218
+
investigate whats new. I found out that the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API)
219
+
is much better than the old `<audio>` tags that I used to use. I had
220
+
to learn how to use it, but it feels much better than the old method
221
+
that included a couple of `setTimeout`s.
222
+
223
+
I'm not sure if the original tetris had sounds or music. For nostalgia
224
+
sake, I included the game theme in the `Menu Screen`. I also added some
225
+
generic blip noises for other commands.
226
+
227
+
I made a class to hide the complexity of dealing with sounds:
228
+
229
+

230
+
231
+
Then I just have to call the sounds whenever they're needed:
0 commit comments