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

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.

主站蜘蛛池模板: 康马县| 缙云县| 渝中区| 贡山| 镇原县| 贞丰县| 黄浦区| 霍城县| 淅川县| 武强县| 萨迦县| 大名县| 青冈县| 贵州省| 安宁市| 马龙县| 黄浦区| 丰城市| 兴业县| 华亭县| 平乡县| 贡嘎县| 武宣县| 洱源县| 天津市| 阿荣旗| 永定县| 贵溪市| 滁州市| 永吉县| 临清市| 瑞安市| 宿州市| 民丰县| 湟中县| 安远县| 中方县| 宜阳县| 永嘉县| 阳泉市| 张掖市|