《面向对象程序设计《面向对象程序设计》》课程设计课程设计题目: 吃豆子游戏程序院系: 数学与计算科学学院专业: 信息与计算科学姓名学号: 覃荣平 1200710128( 组长) 梁隆 1200710123 柳祖发 1200710124 施华官 1200710127 指导老师: 宁黎华日期: 2014 年 12月 30日桂林电子科技大学课程设计报告用纸心得体会: 通过这次课程设计,我从对 MFC 的陌生到能熟练运用基本的函数, 了解其编程的具体实现方法, 我对于面象对向编程有了更深刻的认识,通过四个人的团队合作,我从主持谐调各方面工作, 如听取各方面意见, 看成员整理好的资料,到担任代码编写,学会了团队合作的重要性, 团队合作在写大的程序时比单个人完成有很大的优点。我会继续在面向对象编程上下功夫,因为学无止境。桂林电子科技大学课程设计报告用纸摘要 MFC 是 Windows 编程的面向对象化,是对 Windows 函数的简单封装, 使用 MFC 编程可以在短时间内编写一个 Windows 程序,而不必写大量 Window s代码,所以我使用 MF C编写了一个吃豆子程序,该程序实现了一个能过使用方向键控制消除屏幕上存在的豆子的功能,当用户按键盘向上、下、左、右键或每格一秒钟,嘴的状态发生改变,或是从一个方向张开向另一个方向, 或是由张开变成闭合状态,从而实现嘴一张一合前进,当嘴所经过位置有豆子, 豆子被消除而不再出现,所有豆子被“吃”完时,程序弹出对话框“ You win ,Exit? ”,用户点确定后可退出程序。实现方法:嘴的张开与闭合分别用 MF C 的 Pie 和 Ellipse 函数实现,豆子被存储在一个标记数组中,豆子被吃时数组相应元素标记为零。在 OnDraw() 函数中画出每个豆子和嘴的原始位置,在响应键盘上下左右方向虚拟键 VK_UP 、 VK_DOWN 、 VK_LEFT 、 VK_RIGTH 的函数中控制豆子移动和嘴的方向,程序开始时在响应 WM_CREATE 消息的函数中设置一个 TIMER ,方向键消息和 TIMER 消息统一由一个判断函数处理从而实现自动前进时的沿当前方向前进。关键字: 程序设计豆子 MFC 桂林电子科技大学课程设计报告用纸 Abstract MFC isa Windows-based object-oriented programming, it isa simple package of Windows 'function , using the MFC programming can make us write a Windows program ina short time, without having to write a lotof Windows code, soI use MFC written a eat-beans program ,in this program we can use the arrow keys to control the mouth to move to eliminating the beans on the screen, when the user presses the keyboard up, down, left, right, or each time one second goes by, the state of the mouth changed, it change from one direction to another direction, or from an opening state toa closed state. So we can obtain a mouth moving forward with it's lips keeping closing and opening, ifa bean is in the way of the mouth, it will be eliminated by setting it's element in the mark array as zero. when all beans have bean eaten, a dialog box prompts: "You win, Exit?", after the user clicks OK , the game terminates. Implementation method: We can use the MFC's Pie function to draw a open mouth, while the Ellipse function to draw the closed mouth, all bea
C++课程设计-吃豆子 来自淘豆网m.daumloan.com转载请标明出处.