ImageVerifierCode 换一换
格式:DOCX , 页数:26 ,大小:93.54KB ,
资源ID:17534616      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17534616.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c++实现拼图游戏Word文档下载推荐.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c++实现拼图游戏Word文档下载推荐.docx

1、(要求写详细过程)该部分必须包括:系统结构框图、各模块流程图、关键代码、主要的数据结构、测试与评价等2.12.3头文件(宋体,小三)#include stdh.hclass Boardprivate: int m_bMAXN_BOARDMAXN_BOARD; / empty block position : ex ey / old empty block position oex,oey int m_ex,m_ey; int m_oex,m_oey; int m_dir; / reverse-direction of empty block bool m_bMove; / if the boa

2、rd moved int m_nx,m_ny; int m_nBlock;public: Board(); int Create(); bool Check(); / check if the game win int GetMat(int ,int ); int SetMat(int ,int , int ); int SetXY(int ,int ); int GetEX(); int GetEY(); int GetOEX(); int GetOEY(); int GetDir(); int Move(int , int ); bool CheckMove(); int ResetMov

3、e(); int Up(); int Down(); int Left(); int Right(); int Click(int , int); / when User click the picture int Init();/* Class Flip stored all elements of the flipping-block. It will be used when the clicked block moving to the destination.*/class Flip int m_cnt; int m_ux,m_uy; / uX , uY pixels are mov

4、ed per m_time int m_time; / uSeconds /direction of flip int m_cx,m_cy; / current pos of block int m_sx,m_sy; / source pos of block int m_dx,m_dy; / destination pos of block int GetXY(int , int& , int&); int GetTime(); int SetXY(int ,int ,int ,int ); int SetTime(int ); int SetCnt(int ,int ,int ); int

5、 SetDir(int); bool Finish(HWND ); / check if the flipping overFlip.hBoard.hclass Game Board m_board; Flip m_flip; int m_vFlip; int m_xFlip,m_yFlip; HBITMAP m_hBmp; HBITMAP m_hMemBmp; BITMAP m_bmp; HDC m_mdc,m_bufdc; /double cache HWND m_hWnd; Game(); int SetLevel(int ,int ); int LoadBmp(HINSTANCE,in

6、t); int Init(HWND); / Init the game int Create(HWND); int Paint(HWND); /User clicked the picture int Key(WPARAM); /User push down the keyboard int InitFlip(); / init the m_flip and then flipping start. bool CheckWin(); int Release(HWND );/NO_DEPENDENCIES/ Microsoft Visual C+ generated include file./

7、 Used by res.rc/#define IDB_AC 103#define IDB_BH 104/ Next default values for new objects/ #ifdef APSTUDIO_INVOKED#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NEXT_RESOURCE_VALUE 105#define _APS_NEXT_COMMAND_VALUE 40001#define _APS_NEXT_CONTROL_VALUE 1001#define _APS_NEXT_SYMED_VALUE 101#endif#prag

8、ma once#include ctimecmathusing namespace std;const int MAXN_BOARD = 10;const int CLIENT_X = 1024;const int CLIENT_Y = 768;const int OFFSET_LINE = 1;const int DIR_UP = 0;const int DIR_DOWN = 1;const int DIR_LEFT = 2;const int DIR_RIGHT = 3;const int FLIP_CNT = 8;const int FLIP_TIME = 18;2.2源文件(宋体,小三

9、)Board:Board() memset(m_b,-1,sizeof(m_b); m_nx = m_ny = m_ex = m_ey = 0; m_nBlock = 0;int Board:Create() return 0;SetXY(int nx, int ny) m_nx = nx; m_ny = ny; m_nBlock = m_nx * m_ny; m_oex = m_ex = m_nx - 1; m_oey = m_ey = m_ny - 1;SetMat(int x, int y, int val) m_byx = val; return val;GetMat(int x, i

10、nt y) return m_byx;GetEX() return m_ex;GetEY() return m_ey;GetOEX() return m_oex;GetOEY() return m_oey;GetDir() return m_dir;bool Board:Check() int ck = 0; bool flag = true; for(int i = 0; i m_ny; +i) for(int j = 0; j m_nx; +j) if(ck != m_bij) flag = false; break; +ck; if(flag = false & ck m_nBlock-

11、1) return false; return true;Init() / VARIABLE: nStep , nLoop / / nStep: / In order to generate the random block positions and / to make sure must have a solution, we / have to simulate The-Inverse-Action of the user. / Then nStep mean we will execute the Inverse-Action times. / And each Action will

12、 be random generated. / nLoop: / Due to the reason that the method that above-mentioned has / a big Drawback: if the number of blocks is huge, then method would / only change a small area of all. Avoiding this I add a new variable / nloop, which means a same actions that executed times. It was prove

13、d / that after this improved the new-method work well. int nStep = (rand()&(1Up(); break; case 1:Down(); case 2:Left(); case 3:Right(); Move(int nx, int ny) m_ex = nx; m_ey = ny;CheckMove() return m_bMove;ResetMove() m_bMove = false;Up() Move(m_ex,m_ey); if(m_ey = 0) return -1; m_bm_eym_ex = m_bm_ey

14、-1m_ex; m_bm_ey-1m_ex = -1; -m_ey; m_dir = DIR_DOWN; m_bMove = true;Down() if(m_ey = m_ny - 1) m_bm_eym_ex = m_bm_ey+1m_ex; m_bm_ey+1m_ex = -1; +m_ey; m_dir = DIR_UP;Left() if(m_ex = 0) m_bm_eym_ex = m_bm_eym_ex-1; m_bm_eym_ex-1 = -1; -m_ex; m_dir = DIR_RIGHT;Right() if(m_ex = m_nx - 1) m_bm_eym_ex

15、= m_bm_eym_ex+1; m_bm_eym_ex+1 = -1; +m_ex; m_dir = DIR_LEFT;Click(int x, int y) if(x = m_nx | y = m_ny) if(abs(x-m_ex) + abs(y-m_ey) 1) if(x - m_ex 0) this- return 0; if(m_ex - x if(y - m_ey if(m_ey - y PingTu.hGame:Game() m_nx = m_ny = m_ux = m_uy = 0;int Game:Create(HWND hWnd) m_mdc = CreateCompa

16、tibleDC(GetDC(hWnd); m_bufdc = CreateCompatibleDC(GetDC(hWnd); srand(unsigned(time(NULL); m_board.Create();Init(HWND hWnd) m_ux = m_bmp.bmWidth/m_nx; m_uy = m_bmp.bmHeight/m_ny; m_hWnd = hWnd; m_board.Init(); MoveWindow(hWnd,0,0, m_bmp.bmWidth+m_ux+m_nx*OFFSET_LINE+20, m_bmp.bmHeight+20, TRUE); / in

17、itialize flip m_flip.SetCnt(FLIP_CNT,m_ux,m_uy); m_flip.SetTime(FLIP_TIME);SetLevel(int x, int y) m_nx = x; m_ny = y; m_board.SetXY(x,y);LoadBmp(HINSTANCE hInst, int id) m_hBmp = LoadBitmap(hInst,MAKEINTRESOURCE(id); GetObject(m_hBmp,sizeof(BITMAP),&m_bmp);Paint(HWND hWnd ) int x,y,k,i,j; int cur_bl

18、ock; HDC hdc; hdc = GetDC(hWnd); DeleteObject(m_hMemBmp); m_hMemBmp = CreateCompatibleBitmap(GetDC(hWnd),CLIENT_X,CLIENT_Y); SelectObject(m_mdc,m_hMemBmp); SelectObject(m_bufdc,m_hBmp); cur_block = m_board.GetMat(m_board.GetOEX(),m_board.GetOEY(); for(i = 0; for( j = 0; k = m_board.GetMat(j,i); x =

19、k%m_nx; y = k/m_nx; if( -1 = k ) /StretchBlt(m_mdc,j*m_ux+OFFSET_LINE,i*m_uy+OFFSET_LINE, / m_ux-2*OFFSET_LINE,m_uy-2*OFFSET_LINE, / m_bufdc,0,0,m_bmp.bmWidth,m_bmp.bmHeight,SRCCOPY); continue; else if( k = cur_block & !m_flip.Finish(hWnd) ) m_flip.GetXY(m_board.GetDir(),x,y); BitBlt(m_mdc,x,y,m_ux,

20、m_uy, m_bufdc,(k%m_nx)*m_ux,(k/m_nx)*m_uy,SRCCOPY); else BitBlt(m_mdc,j*(m_ux+(OFFSET_LINE1)+(OFFSET_LINE), i*(m_uy+(OFFSET_LINE1)+OFFSET_LINE,m_ux,m_uy, m_bufdc,x*m_ux,y*m_uy,SRCCOPY); BitBlt(hdc,0,0,m_bmp.bmWidth,m_bmp.bmHeight,m_mdc,0,0,SRCCOPY); StretchBlt(hdc,m_bmp.bmWidth,0,m_ux,m_uy, m_bufdc,0,0,m_bmp.bmWidth,m_bmp.bmHeight,SRCCOPY);Click(int mx, int my)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1