The goal of the application is to create a javascript version of tetris that uses object oriented programming to solve the problem.
As a user, I should be able to:
- Start the game
- get a random falling shape every x seconds
- rotate the shape
- move the shape left, right, down
- pause the game
- see the next shape that will fall
- clear complete lines from the board (no spaces across a row)
- keep track of the number of lines cleared
- recognize when the player has lost the game (ran out of space)
- General game play
- Start the game
- pause the game
- random falling shape
- Shape
- rotate
- move left, right down
- Grid
- Positioning on the board
- ran out of space
- Grid - The 2d grid of squares that a tetris shape moves through. Can check for lines that should be cleared and clears lines. Can also check for a collision given a tetromino
- Has: linesToClear, addToGrid(tetromino), checkCollisions(tetromino), clear, hasLost
- Responsible for drawing itself and any squares that have collided
- Point - 2D point that saves x and y
- Shape - Composed of an array of points and a color for the squares
- Responsible for finding all points that are on the bottom of the shape
- Tetromino - The tetris game piece. Composed of a shape. Has a factory that randomly generates a tetromino.
- Has: move, rotate
- Responsible for drawing itself on the screen before it becomes part of the grid
- Tetris - Handles starting the game, pausing the game, handling key presses for moving the falling tetromino. Keeps track of next shape
- Has: checkCollisions, newFallingTetromino, play, pause
- Responsible for calling draw on grid and falling shape
Great outline👌🏻 thanks.