Setup (requires node.js):
> npm install
Start tests:
> npm test
Serve up the App (and ctrl-click the URL that appears in the console)
> npm run dev
There are a few files you may wish to modify. The rest should not be modified as they are used for configuring the build.
src/main.ts
- Code file used as the entry point
- Most of your game logic should go here
- Contains main function that is called on page load
src/style.css
- Stylesheet
- You may edit this if you wish
index.html
- Main html file
- Contains scaffold of game window and some sample shapes
- Feel free to add to this, but avoid changing the existing code, especially the
idfields
test/*.test.ts
We expect the core logic of your game to be in src/main.ts, however, you may elect to spread your code over multiple files. In this case, please use .
Avoid separating code into too many files as it makes it hard to mark. The maximum recommended code file structure would be something like
src/
main.ts -- main code logic inc. core game loop
types.ts -- common types and type aliases
util.ts -- util functions
state.ts -- state processing and transformation
view.ts -- rendering
observable.ts -- functions to create Observable streams
Before playing the Tetris game, know about below: Blocks: I: [ { x: 4, y: 0 }, { x: 4, y: 1 }, { x: 4, y: 2 }, { x: 4, y: 3 }, ], O: [ { x: 4, y: 0 }, { x: 5, y: 0 }, { x: 4, y: 1 }, { x: 5, y: 1 } ], T: [ { x: 4, y: 0 }, { x: 3, y: 1 }, { x: 4, y: 1 }, { x: 5, y: 1 } ], S: [ { x: 4, y: 0 }, { x: 5, y: 0 }, { x: 3, y: 1 }, { x: 4, y: 1 } ], Z: [ { x: 3, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 1 }, { x: 5, y: 1 } ], J: [ { x: 3, y: 0 }, { x: 3, y: 1 }, { x: 4, y: 1 }, { x: 5, y: 1 } ], L: [ { x: 5, y: 0 }, { x: 3, y: 1 }, { x: 4, y: 1 }, { x: 5, y: 1 } ]
To play the Tetris game, know about the controls below:
- Key P -- pause game
- Key R -- restart game
- Key A -- move left
- Key D -- move right
- Key T -- rotate block
Enjoy the game!