A language a year keeps the doc away!
Don’t be fooled by the name TypeTris. There is no actual typing involved.
The source code contains a few classes and ~ 330 lines of code. So if you are familiar with TypeScript or Tetris you can easily read along and learn one or the other.
Play it! Source code Download ZIP
Use cursor keys ▲ ▶ ▼ ◀ SPACE or
I J K L M SPACE to control the game.
P to pause.
Build & run
Then open typetris.html in your browser.
A word about browser compatibility
This project use the TypeScript compiler to transpile TypeScript → ES6. So it works in current browsers:
- Edge (76 or higher due to
Internet Explorer is not a target (well, not in that way).
Used & unused TypeScript features
I think the best way to learn the basics of a language is just do it™ but it implies overseeing important parts of a language.
I used tslint though with some rules to my liking (see tslint.json), I would like to hear from you about how to do things in an idiomatic way.
Except TypeScript’s type system there is much more but I hesitated to use mixins, decorators, modules, etc. but show me if you know good use for them.
The polymorphic renderer
Rendering is implemented by adhering to
IRenderer which has only two methods (draw and score). A default
CanvasRenderer is provided, but you can implement your own (e.g.
ASCIIRenderer) by implementing those two methods.
|tsconfig.json||JSON||Jan ’20||134 bytes||Preview Download|
|tslint.json||JSON||Jan ’20||416 bytes||Preview Download|
|typetris.html||HTML||Mar ’20||303 bytes||Preview Download|
|typetris.js.map||map file||Jun ’20||12.8 kB||Preview Download|
|typetris.png||PNG image||Jan ’20||5.0 kB||Preview Download|
|typetris.svg||SVG image||Dec ’21||2.4 kB||Preview Download|
|typetris.ts||TypeScript||Jun ’20||10.4 kB||Preview Download|
|typetris.zip||Zip archive||Jun ’20||12.5 kB||Preview Download|
|9 files||53.7 kB|