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

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.

主站蜘蛛池模板: 福鼎市| 泾阳县| 平利县| 呼玛县| 隆尧县| 和林格尔县| 永和县| 阿图什市| 于田县| 龙陵县| 东山县| 海淀区| 滨州市| 开原市| 常德市| 特克斯县| 凌海市| 钟祥市| 广南县| 巴林左旗| 色达县| 枣强县| 夏邑县| 仙游县| 思茅市| 滦平县| 铜陵市| 黔江区| 曲松县| 大连市| 普陀区| 乳山市| 犍为县| 遂溪县| 琼海市| 正安县| 南乐县| 清远市| 分宜县| 保靖县| 武宁县|