基于单片机的俄罗斯方块游戏
 
俄罗斯方块作为最经典的电子游戏之一,它曾经引起的轰动真是不容小觑。本设计是在12C5A60SR单片机的基础上利用C语言编程,做出实物电路图来模拟俄罗斯方块小游戏的设计。游戏需要利用按键控制方块运动,玩家可以以90度为单位旋转方块,以格子为单位左右移动方块,当区域中某一行全部由方块填满时,则该行会消失并记分,同时消除的列数越多,得分越多;当方块堆到区域最上方而无法消除时,游戏结束。
游戏设计主要分为硬件电路设计和源代码编写两部分。对于硬件电路,有必要充分了解核心单片机的外部接口功能,液晶显示器需要处理的逻辑关系和它控制原理,以及键盘设置所需的程序。而对于编程方面首先定义一个二维数组确定整个区域,了解游戏中所需要用到的一些特殊的函数,然后判断区域是否有方块,还要判断方块落下后,一行的空格是否填满或者整个区域是否填满等,不断的按照这样的方法循环扫描。
    实际运行表明,该设计可以实现基本的游戏功能,达到游戏的目的。
关键词】12C5A60SR;LCD液晶;C语言
Tetris game based on single chip microcomputer
 
Abstract
    电子游戏的利与弊Tetris is one of the most classic electronic game, it had caused a sensation is really can not be underestimated. This design is the use of C programming language based on 12C5A60SR microcontroller, design the physical circuit diagrams to model the Tetris game. The game needs to use the keys to control block movement, game player can be 90 degrees rotate, by a lattice units moving boxes around, when the region in a row are filled by the box, the guild to disappear and score, the number of columns, and eliminate scores more; when the box at the top of pile to areas not to eliminate, the end of the game.
    Game design is divided into hardware circuit design and source code in two parts. For the hardware circuit, it is necessary to fully understand the external interface functions of th
e core MCU, LCD need logic processing and its control principle, and procedures required for keyboard settings. For programming the entire region defined first determine a two-dimensional array, understand some special function required in the game, and then determine whether to judge the regional block, block falls, a row space is filled or the whole area is filled, circular in accordance with this method of scanning time.
    The actual operation shows that, the design can achieve the basic game functions, achieve the goal of the game.
Key words12C5A60SR; LCD liquid cryst; C language
     
1 绪  论    1
致  谢    19