A simple tetris game built using RxJS and TypeScript
Demo here
Setup (requires node.js):
> npm install
Serve up the App (and ctrl-click the URL that appears in the console)
> npm run dev
Cube is a 1x1 object
Block is an object made up of 4 cubes in any tetris shape
Rotation system used is a Super Rotation System (SRS) where it is possible to rotate a block 90 degrees clockwise or anticlockwise
constants.ts: contains constants used in the gamegame.ts: contains the game logictypes.ts: contains the types used in the gameobservables.ts: sets up the observables used in the gamegenerics.tscontains generic functions that can be used anywhere where the types are relevantviews.ts: contains the functions that render the gameshapes.ts: contains the functions that generate the various tetris shaped blocksutil.ts: contains utility function(s)main.ts: contains the main function that runs the game loop
- The game is over when a block reaches the top of the game board
- 100 points are awarded for each row cleared
- The game speed increases after reaching 200 score
- The game restarts automatically after showing game over box briefly
- Highscore is tracked until page is refreshed
factors like game speed, difficulty based on score, scoring etc. can be tweaked in the constants.ts file
Abutton: Move block leftDbutton: Move block rightSbutton: Move block downHbutton: Hold the block (more on this in Report)Ebutton: Rotate block clockwiseQbutton: Rotate block anti-clockwiseRbutton: Restart game