The operation AddBlock has an input variable occupied ? denoting the posi- tions of the playing screen occupied by the block. The precondition requires that there exists a position x y occupied by the block which is either at the bottom of the playing screen — y 0 — or immediately above an occupied position — x y 1 occupied . The postcondition requires that the positions occupied bythe are added to the occupied positions of the playing screen.The precondition of the operation RemoveRow requires that there exists a rowy in which all positions are occupied — x : 0 width 1 x y occupied . The postcondition requires that all occupied positions of the playing screen i j below this row — that is, with j y — remain occupied and all occupied positions i j above the row — that is, with j y — shift down one row to i j 1 . The occupied positions in row y are effectively removed from the playing screen. The blocks in Tetris come in seven different shapes. Each block can be mod- elled as a square grid object comprising either 4, 9 or 16 positions and with four positions occupied. The different blocks are shown in this form in Figure 1.5.
đang được dịch, vui lòng đợi..