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

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.

主站蜘蛛池模板: 新蔡县| 夏河县| 永春县| 深水埗区| 上虞市| 海盐县| 河西区| 隆子县| 永兴县| 磴口县| 左贡县| 甘肃省| 宿迁市| 广安市| 高碑店市| 大竹县| 铜陵市| 靖西县| 仁怀市| 分宜县| 华坪县| 永仁县| 荆州市| 宁城县| 安顺市| 中牟县| 屯留县| 广安市| 政和县| 彩票| 肇庆市| 扎鲁特旗| 石狮市| 临洮县| 合肥市| 隆尧县| 汕头市| 绥棱县| 丰台区| 灌云县| 广饶县|