Download presentation

Presentation is loading. Please wait.

Published byJade Manning Modified over 2 years ago

1
Tetris

2
Informal description Tetris is a 2d computer game. It consists of an Matrix and we have Tiles. One new tile is introduced at a time and enters from the top of the game area. For each ClockTick the whole Tile moves one Unit downwards. And the user can control the FallingTile by rotating and shifting. A FallingTile becomes inactive when it hits an occupied Cell or the bottom of the Area. A row is cleared as soon as all Cells in it are occupied. All the occupied Cells above it moves down one Cell. Game over when the pile of blocks hits the ‘ceil’ of the area

3
Definitions Cell = rendered square area o Cell.occupied = x E [0,1] o Cell.color = color code o Cell.active = x E [false,true] Type Matrix = rectangular form which shape is dictated by Rows × Columns GameMatrix :: Matrix Rows= Columns= Celli,j = (Rowi, Columnj) Tile is a Matrix whose number of rows and columns are less than or equal to the GameMatrix. Tile = 1..* Cells. For all Cell1, Cell2, that are part of Tile this holds: Reachable(Cell1,Cell2)

4
Definitions (ctd) Reachable(Celi,j,Cellm,n) = ((|m – i| =1 AND j = n) OR (|j – n| = 1 AND i = m)) OR There exists a Cellk,l such that IF Reachable (Celli,j, Cellk,l) AND Reachable(Cellk,l,Cellm,n) THEN Reachable(Celli,j, Cellm,n)

5
Definitions (ctd) Clock ticks form a series of equally distributed points in time. o Simplyfing assumption: ClockTicks at the end of equal time intervals. In that series: for each predecessor t1 of each Tick t2 (if any) it holds that time of t1 < time of t2 Clock tick = the base measure of time

6
Actions These actions must be initiated by the User input: o SL = moves a Tile one Cell to the left in the Area o SR = moves a Tile one Cell to the right in the Area o RL = rotates a Tile 90 degrees left o RR = rotates a Tile 90 degrees right Invariant: Each ClockTick the Tile moves down one Cell Invariant: Each action results in an screen update

7
Rendering on screen Every cell is rendered as a square A rectangle must represent the GameMatrix. o Size of rectangle should be configurable -- so for instance it can be fullscreen o Width and height of the GameMatrix are dependent upon each other, because of the constraint that the contained cells must appear as squares. The rectangle is populated by cells according to their row/column indexes.

8
Initial State / New Game Initial State: o GameMatrix doesn't have any inactive Cells. o A new Tile is generated o Program starts to generate Clock Ticks.

9
End State / Game over Program stops to generate Clock Ticks. Gives the user an option to start a new game, which brings the program in Initial State, or to exit the program.

10
New Tile When a New Tile is generated, the highest Cell of the Tile is on the highest row of the GameMatrix, if the cells to occupy were not occupied before. Otherwise the game is over, which is the EndState. The Cell positions of the Tile are marked as active within the GameMatrix.

11
Downward movement For each Clock Tick the falling Tile moves one Cell to the Bottom, unless the falling Tile is a StuckTile. In the latter case, a new falling Tile is generated. StuckTile is a Tile which has Cells that are on the same level as the lowest level of Area OR StuckTile is block which has Tile that are just one level higher than one or more Tile of an other StuckBlock.

12
Action: Shift left/right Function MoveRight() For All active cells s in GameMatrix If cell[s.x-1,s.y].occupied = false flag = true else flag = false return For All active cells s Cell(s.x,s.y).active = false Cell(s.x-1,s.y).active = true MoveLeft is the same, but replace all occurences within the function MoveRight of 'x-1' with 'x+1' excluding quotation marks.

13
Action: Rotate

Similar presentations

OK

Team 22 沈昇勳、李宗儒、洪銘駿. Among EE students, one particular game is especially popular and has many devoted players: LUMINES. FOREWORDS.

Team 22 沈昇勳、李宗儒、洪銘駿. Among EE students, one particular game is especially popular and has many devoted players: LUMINES. FOREWORDS.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on upcoming technologies in computer science Ppt on 9/11 conspiracy Ppt on charge coupled device Ppt on sectors of economy for class 10 Ppt on history of vedic maths pdf Download ppt on social media marketing Ppt on unified power quality conditioner Ppt on eddy current brakes Ppt on magic garden Ppt on bluetooth communication protocol