毕业设计(论文)-VC++6.0简易连线游戏个人尝试版【含源程序】.doc_第1页
毕业设计(论文)-VC++6.0简易连线游戏个人尝试版【含源程序】.doc_第2页
毕业设计(论文)-VC++6.0简易连线游戏个人尝试版【含源程序】.doc_第3页
毕业设计(论文)-VC++6.0简易连线游戏个人尝试版【含源程序】.doc_第4页
毕业设计(论文)-VC++6.0简易连线游戏个人尝试版【含源程序】.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 目 录 1 前言 2 2 需求分析 2 2 1 系统运行环境 3 3 概要设计 3 3 1 数据流图 3 3 2 系统功能模块设计 4 3 3 流程图 4 4 详细设计 5 4 1 系统界面的实现 5 4 2 程序实现相关源码 5 5 测试分析 20 6 心得体会 20 参考文献 20 致 谢 21 源程序代码 加源程序代码 加 153893706153893706 2 简易连线游戏个人尝试版 摘 要 本次课程设计的主要任务是通过设计出一个简易穿线游戏 使用可视化的 Visual C 6 0 软件实现穿线游戏 并学会使用面向对象的消息驱动机制 处理各种消息事 件并做出适当的响应 本次课程设计通过对计时器等消息机制的应用 在经过参考各 种资料 并在指导老师的帮助下 基本上成功地实现了设计任务书的要求 关键字 简易连线游戏 计时器 case 条件 Simple Thread Games Personal Try Edition Abstract The curriculum design of the main tasks is to design a simple Thread games Visual C 6 0 Visual Software is using in the Thread games And learning how to use object oriented message driven mechanism to deal with all kinds of news events and make an appropriate response The curriculum design of the timer mechanism of such information after taking into account information and the instructor s help basically the design of the successful implementation of the requests Keywords Summary Thread games case Conditions timer 1 前言 近年来 随着信息技术的迅速崛起 高效的软件管理已成为收集提供信息 3 的最佳渠道并逐步进入传统教学的流通领域 教学软件服务也随之开始流行起 来 越来越多的教育管理者使用教学管理软件 作为一种融入教育现代化的全 新理念 本简易穿线游戏系本人尝试所作 其功能较为简单 多有不完善之处 还恳请多多包涵和谅解 谢谢 本程序是使用了计时器原理 情况选择循环功能 面板刷新机制 线条描 摹等等机制 下面 就本程序 谈谈其开发过程和所涉及到的问题及解决方法 2 需求分析 Visual C 6 0 的 MFC 提供了对数据库的强大支持 曾几何时 我们还是 孩提时 也曾玩过用针线穿纽扣的游戏 其游戏规则在于 目的 在本游戏中 你将作为一名裁缝 将尽可能多的纽扣穿成一个闭合的路 线 游戏初始有 15 个纽扣 随着时间的增加 纽扣数目也增加 当达到 70 个 时游戏即结束 规则 只能在有纽扣的点穿线 且只能在水平方向或竖直方向穿线 线可交叉 但有纽扣的点不能交叉连接 秘诀 要尽可能使连线长且该连线上的纽扣数多 就以上需求及其功能 开始下面的设计 2 1 系统运行环境 硬件环境 本系统适用于那种 Inter386 以上计算机 内存容量为 128M 应配备 键盘 鼠标 显示器等外部设备 软件环境 本系统的设计采用 Visual C 6 0 编写 在 Windows XP SP2 环境下测试通过 4 3 概要设计 3 1 数据流图 数据流图是对系统数据流向的一种描述 并从本质上让程序的使用者 大致了解系统的使 用方法 本简易穿线游戏的大致流程图如下 游戏面板设计 穿线游戏 菜单面板设计菜单消息机制游戏机制实现 3 2 系统功能模块设计 系统功能模块是对软件所具功能的基本概述 本学生请假管理系统的模块大致可以划 分如下图所示 游戏面板设计 穿线游戏 菜单面板设计菜单消息机制游戏机制实现 图 3 2 功能模块 5 3 3 流程图 图 3 3 流程图 4 详细设计 4 1 系统界面的实现 程序界面程序在启动运行时 系统会通过调用视图类中的重绘图函数对界 面进行界面的初始化 使程序界面更加友好 在使用上给用户一种清新怡然的 感觉 其界面如图所示 图 4 1 游戏运行界面 N 游戏等级选择 进入游戏面板 Y 开 始 结 束 开始游戏 游戏结束 6 4 2 程序实现相关源码 chuangniu cpp 文件中 include include resource h include chuanniu h include time h LRESULT CALLBACK WndProc HWND UINT WPARAM LPARAM 结果 static HBITMAP hBitmap 20 位图 int Map 12 12 bakMap 12 12 int QiziNumber 70 目标个数 int WINAPI WinMain HINSTANCE hInstance HINSTANCE hPrevInstance PSTR szCmdLine int iCmdShow static TCHAR szAppName ChuanNiukou HWND hwnd HBRUSH hBrush 刷 HBITMAP hMainBitmap MSG msg WNDCLASS wndclass hMainBitmap LoadBitmap hInstance main 加载位图 hBrush CreatePatternBrush hMainBitmap 创建模式刷新 DeleteObject hMainBitmap wndclass style CS HREDRAW CS VREDRAW wndclass lpfnWndProc WndProc wndclass cbClsExtra 0 wndclass cbWndExtra 0 wndclass hInstance hInstance wndclass hIcon LoadIcon hInstance szAppName wndclass hCursor LoadCursor NULL IDC ARROW wndclass hbrBackground hBrush wndclass lpszMenuName szAppName wndclass lpszClassName szAppName if RegisterClass return 0 7 hwnd CreateWindow szAppName TEXT 简易连线游戏 个人尝试版 WS CAPTION WS SYSMENU WS MINIMIZEBOX 150 150 453 341 NULL NULL hInstance NULL ShowWindow hwnd iCmdShow UpdateWindow hwnd while GetMessage DispatchMessage DeleteObject hBrush return msg wParam LRESULT CALLBACK WndProc HWND hwnd UINT message WPARAM wParam LPARAM lParam static HWND hchildwnd1 hchildwnd2 hchildwnd3 static int Level IDM FIRST static HMENU hMenu static BOOL ifBegin FALSE int x y static int xSource 0 ySource 0 iflag 0 HDC hdc HINSTANCE hInstance TCHAR szJibie 30 TCHAR szFenshu 30 int xposition yposition PAINTSTRUCT ps switch message case WM CREATE hMenu GetMenu hwnd hInstance LPCREATESTRUCT lParam hInstance ClearQipan LoadAllBitmap hInstance hchildwnd2 CreateWindow static 剩余 70 WS CHILD WS VISIBLE WS EX STATICEDGE SS CENTERIMAGE 280 120 8 130 30 hwnd HMENU 2 hInstance NULL hchildwnd3 CreateWindow static 游戏级别 1 WS CHILD WS VISIBLE WS EX STATICEDGE SS CENTERIMAGE 280 190 130 30 hw nd HMENU 3 hInstance NULL return 0 case WM PAINT hdc BeginPaint hwnd DrawJiemian hchildwnd1 hchildwnd2 hchildwnd3 hdc DrawQipan hdc hInstance hwnd EndPaint hwnd return 0 case WM COMMAND switch LOWORD wParam case IDM BEGINGAME KillTimer hwnd Level iflag 0 QiziNumber 70 InitQiziLink ifBegin TRUE ClearQipan InitLink DrawQizi 15 hwnd hchildwnd2 IDT NIU EnableMenuItem hMenu IDM PAUSEGAME MF ENABLED EnableMenuItem hMenu IDM GAMEOVER MF ENABLED for x 1 x 6 x EnableMenuItem hMenu x MF GRAYED SetTimer hwnd Level 1200 Level NULL return 0 case IDM PAUSEGAME EnableMenuItem hMenu IDM BEGINGAME MF GRAYED EnableMenuItem hMenu IDM GAMEOVER MF GRAYED ModifyMenu hMenu IDM PAUSEGAME NULL IDM GOON 游戏继续 F3 KillTimer hwnd Level ifBegin FALSE return 0 case IDM GOON EnableMenuItem hMenu IDM BEGINGAME MF ENABLED EnableMenuItem hMenu IDM GAMEOVER MF ENABLED ModifyMenu hMenu IDM GOON NULL IDM PAUSEGAME 游戏暂停 F3 SetTimer hwnd Level 1200 Level NULL ifBegin TRUE 9 return 0 case IDM FIRST case IDM SECOND case IDM THIRD case IDM FORTH case IDM FIFTH case IDM SIXTH CheckMenuItem hMenu Level MF UNCHECKED Level LOWORD wParam CheckMenuItem hMenu Level MF CHECKED wsprintf szJibie 游戏级别 d Level SetWindowText hchildwnd3 szJibie return 0 case IDM ABOUT MessageBox hwnd 04 计 2 班田华 n2007 年 1 月 10 日 nhttp di nE maill supersaviors 简易连线游戏 个人尝试版 NULL return 0 return 0 case IDM GAMEOVER KillTimer hwnd Level EnableMenuItem hMenu IDM PAUSEGAME MF GRAYED EnableMenuItem hMenu IDM GAMEOVER MF GRAYED ifBegin FALSE for x 1 x 0 ySource yposition 10 return 0 case WM RBUTTONDOWN for x 0 x 12 x for y 0 y 12 y Map x y bakMap x y iflag 0 InvalidateRect hwnd NULL FALSE ShuaXinLink hchildwnd2 return 0 case WM TIMER DrawQizi 1 hwnd hchildwnd2 IDT NIU if QiziNumber 0 KillTimer hwnd Level MessageBox hwnd 不好意思哦 游戏结束 初次尝试 请多多关照 简易连线游戏 个人尝试版 NULL ifBegin FALSE EnableMenuItem hMenu IDM PAUSEGAME MF GRAYED EnableMenuItem hMenu IDM GAMEOVER MF GRAYED for x 1 x 6 x EnableMenuItem hMenu x MF ENABLED return 0 case WM DESTROY DeleteAllBitmap KillTimer hwnd Level PostQuitMessage 0 return 0 return DefWindowProc hwnd message wParam lParam void DrawJiemian HWND hchildwnd1 HWND hchildwnd2 HWND hchildwnd3 HDC hdc RECT rectmain rectfen rectone recttwo rectthree rectmain left 14 rectmain top 14 rectmain right 270 rectmain bottom 270 rectfen left 272 rectfen right 425 rectfen top 14 rectfen bottom 270 rectone left 279 rectone right 412 rectone top 49 rectone bottom 82 recttwo left 279 recttwo right 412 recttwo top 119 recttwo bottom 152 rectthree left 279 rectthree right 412 rectthree top 189 rectthree bottom 222 DrawEdge hdc 11 DrawEdge hdc DrawEdge hdc DrawEdge hdc DrawEdge hdc void DrawQipan HDC hdc HINSTANCE hInstance HWND hwnd int x y HDC hdcMem hdcMem CreateCompatibleDC hdc for y 0 y 12 21 y y 21 for x 0 x 12 21 x x 21 SelectObject hdcMem hBitmap Map x 21 y 21 1 BitBlt hdc x 16 y 16 21 21 hdcMem 0 0 SRCCOPY DeleteDC hdcMem void LoadAllBitmap HINSTANCE hInstance int i for i 0 i 20 i hBitmap i LoadBitmap hInstance MAKEINTRESOURCE i 1 void DeleteAllBitmap void int i for i 0 i 16 n void InitSeed void Seed time 0 void InitLink void 12 int i nodehead hang 1 nodehead lie 1 nodehead link 0 for i 0 i 144 i mapbiao i hang i 12 mapbiao i lie i 12 mapbiao i link i 1 nodenum 144 void DrawQizi int iniunum HWND hwnd HWND hchildwnd2 int nID int i j num r TCHAR szShengyu 30 InitSeed for i 0 i iniunum i r RandNumber nodenum for j nodehead link num 0 num r j mapbiao j link num if num 1 r Map mapbiao mapbiao j link hang mapbiao mapbiao j link lie nID bakMap mapbiao mapbiao j link hang mapbiao mapbiao j link lie nID mapbiao j link mapbiao mapbiao j link link if r 0 nodehead link mapbiao j link Map mapbiao j hang mapbiao j lie nID bakMap mapbiao j hang mapbiao j lie nID nodenum QiziNumber wsprintf szShengyu 剩余 d QiziNumber SetWindowText hchildwnd2 szShengyu InvalidateRect hwnd NULL FALSE void ClearQipan void 13 int i j for i 0 i 12 i for j 0 j 12 j Map i j IDT KONG bakMap i j Map i j void DrawOneQizi int x int y int nID HWND hwnd Map x y nID InvalidateRect hwnd NULL FALSE BOOL DrawLine int xSource int ySource int xTarget int yTarget HWND hwnd int iflag HWND hchildwnd2 int i temp if iflag 0 iflag 1 DrawOneQizi xTarget yTarget IDT LNIU hwnd QiziLink 0 hang xTarget QiziLink 0 lie yTarget QiziLink 0 link 10 ChuanQiziNum 1 return TRUE if xTarget QiziLink 0 hang QiziLink 0 link 1 temp Map xTarget yTarget Map xTarget yTarget IDT NIU if DrawLine xSource ySource xTarget yTarget hwnd iflag hchildwnd2 for i 0 i ChuanQiziNum i Map QiziLink i hang QiziLink i lie IDT KONG bakMap QiziLink i hang QiziLink i lie IDT KONG InvalidateRect hwnd NULL FALSE InitQiziLink 14 iflag 0 ShuaXinLink hchildwnd2 else Map xTarget yTarget temp QiziLink 0 link 10 return FALSE if xSource xTarget if xSource xTarget i yTarget i if Map xSource i IDT KONG for i ySource iyTarget for i ySource 1 i yTarget i if Map xSource i IDT KONG for i ySource i yTarget i switch Map xSource i case IDT KONG Map xSource i IDT KONGXC DeleteNode xSource i break case IDT NIU Map xSource i IDT XIANXC break case IDT KONGYC Map xSource i IDT KONGJ break case IDT LNIU Map xSource i IDT XIANSHANG break case IDT LXIANXIA Map xSource i IDT XIANXC break case IDT LXIANYOU Map xSource i IDT XIANSY 16 break case IDT LXIANZUO Map xSource i IDT XIANSZ break QiziLink ChuanQiziNum hang xSource QiziLink ChuanQiziNum lie i ChuanQiziNum Map xSource i IDT LXIANXIA if xSource xTarget i xTarget i if Map i ySource IDT KONG for i xSource ixTarget for i xSource 1 i xTarget i if Map i ySource IDT KONG for i xSource i xTarget i switch Map i ySource case IDT KONG Map i ySource IDT KONGYC DeleteNode i ySource break case IDT NIU Map i ySource IDT XIANYC break case IDT KONGXC Map i ySource IDT KONGJ break case IDT LNIU Map i ySource IDT XIANZUO break case IDT LXIANSHANG Map i ySource IDT XIANSZ break case IDT LXIANXIA Map i ySource IDT XIANXZ break 18 case IDT LXIANYOU Map i ySource IDT XIANYC break QiziLink ChuanQiziNum hang i QiziLink ChuanQiziNum lie ySource ChuanQiziNum Map i ySource IDT LXIANYOU InvalidateRect hwnd NULL FALSE return TRUE int DeleteNode int x int y int j nodehead link num k nodehead link if mapbiao nodehead link hang x nodenum return 1 for j mapbiao nodehead link link num 0 num nodenum j mapbiao j link num if mapbiao

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论