官术网_书友最值得收藏!

Writing Tetris

First, let's review the Tetris rules (just in case):

  • There is a grid with a height of 16 blocks and a width of 10 blocks.
  • You have seven different tetrimino (a tetris piece) that are all composed of four blocks.
  • A new tetrimino appears at the top of the game's grid every time the previous one cannot descend any more (because the block below is already occupied or because you've reached the game's floor).
  • The game is over when a new tetrimino cannot appear anymore (because there is already a tetrimino at the top of the grid).
  • Every time a line is full (all blocks are occupied by a tetrimino part), it disappears and all lines above descend by one line.

Now that we all agree on the game rules, let's see how to actually write those mechanisms.

First, we need to actually create those tetriminos.

主站蜘蛛池模板: 乌鲁木齐县| 穆棱市| 清镇市| 临安市| 青河县| 宁波市| 东乡族自治县| 五家渠市| 磴口县| 宜春市| 阿合奇县| 宁都县| 曲靖市| 黎平县| 温泉县| 会东县| 甘德县| 天镇县| 兴安盟| 汪清县| 尚义县| 大荔县| 平陆县| 阿图什市| 仲巴县| 含山县| 葫芦岛市| 大安市| 花莲市| 潍坊市| 古蔺县| 舒城县| 怀柔区| 武鸣县| 四子王旗| 崇州市| 黔东| 原阳县| 广南县| 达尔| 新沂市|