1、 基于 MFC 的俄罗斯方块游戏的设计与实现 摘 要 俄罗斯方块是一个人尽皆知的小游戏,在早些年曾经风靡全球。本文介绍了俄罗斯方块游戏, 并详细的阐述了其实现过程。本文中俄罗斯方块游戏是以 MFC 为基础来进行设计与实现。其具体内 容如下: (1)方块的设计,介绍了方块的具体实现方法,方块的随机生成算法,方块的移动、变形的判 断和操作; (2)游戏的开始、暂停、结束等的控制; (3)游戏的选择设置及优化设置,选择设置包括游戏区域大小、难度级别和方块颜色的设置, 优化设置包括游戏时是否需要背景网格以及是否播放背景音乐的设置。 关键词:电子游戏;算法;MFC The design and impl
2、ementation of the Tetris game based on MFC Abstract Tetris is a well known game, and in the early years it has swept the world. This article introduces the Tetris game and elaborates the process of its realization. In this article the Tetris game is designed and implemented based on MFC. Its concret
3、e content is as follows: (1)The blocks design introduces the concrete realization method of block, the random generation algorithm of the block, the blocks movement, deformation of the judgment and operation; (2)The games control is about the beginning, pausing and ending; (3) Its about the games se
4、lect settings and optimization settings. The select settings include the game area size, difficulty level and the color of the blocks set. And the optimization settings include the game whether needs background grid and playing background musics set. Key words: electronic game; calculate; MFC I 目录 1
5、 引言 1 1.1 背景 . 1 1.2 游戏的组成要素 . 1 1.3 Visual C+ 6.0 编程特点 . 2 1.4 面向对象软件开发过程及思想 . 2 1.5 MFC 简介. 3 2 可行性研究与需求分析 5 2.1 可行性研究 . 5 2.1.1 设计目的 5 2.1.2 可行性研究前提 5 2.1.3 可行性分析 5 2.2 需求分析 . 6 2.2.1 引言 6 2.2.2 游戏需求 6 3 概要设计 7 3.1 系统流程 . 7 3.2 功能模块结构设计 . 8 4 详细设计 9 4.1 游戏总体设计 . 9 4.2 游戏中运行窗口绘制 . 10 4.3 方块设计 . 11
6、 4.3.1 方块的实现 11 4.3.2 方块的移动 12 4.3.3 方块的旋转 13 4.3.4 方块的随机性 14 4.4 游戏控制设计 . 14 4.4.1 消行判断 14 4.4.2 游戏难度级别选择 16 4.4.3 游戏背景网格的转换 16 4.4.4 游戏区域大小的选择 16 4.4.5 游戏加分规则 16 4.4.6 游戏结束判断 17 II 4.5 程序运行流程 . 17 4.5.1 初始化 17 4.5.2 创建窗口 18 4.5.3 绘制游戏区域 18 5 系统测试 19 5.1 测试的意义及注意事项 . 19 5.2 游戏界面菜单选项的功能测试 . 20 5.2.1 控制菜单测试 20 5.2.2 设置菜单测试 22 5.3 按键事件的功能测试 . 23 5.3.1 方块移动测试 23 5.3.2 方块变换测试 24 5.4 方块堆砌与消行测试 . 24 5.5 测试结果分析 . 25 6 总结 26 致 谢 27 参考文献 28 第一章 引言 1 1 1 引言引言 1.1 1.1 背景背景 电子游戏,也就是运行在家用电脑、家用电子游戏机