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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

C++写的俄罗斯方块源代码+开发文档.docx

1、C+写的俄罗斯方块源代码+开发文档0 20 40 60 20 40 60 每一点取的是左上角坐标 20,60, 20,40, 20,20, 40,60, RED, 1, 0,60, 20,60, 40,40, 40,60, RED, 2, 20,20, 40,20, 40,40, 40,60, RED, 3, 0,60, 0,40, 20,40, 40,40, RED, 0, 20,60, 20,40, 20,20, 40,20, YELLOW,1, 0,40, 0,60, 20,60, 40,60, YELLOW,2, 20,60, 40,60, 40,40, 40,20, YELLOW,3

2、, 0,40, 20,40, 40,40, 40,60, YELLOW,0, 0,60, 20,60, 20,40, 40,60, GREEN,1, 0,40, 20,60, 20,40, 20,20, GREEN,2, 0,40, 20,40, 20,60, 40,40, GREEN,3, 20,20, 20,40, 20,60, 40,40, GREEN,0, 0,60, 20,60, 20,40, 40,40, WHITE,1, 0,40, 0,20, 20,40, 20,60, WHITE,0, 20,0, 20,20, 20,40, 20,60, LIGHTGRAY,1, 0,40,

3、 20,40, 40,40, 60,40, LIGHTGRAY,0, 20,20, 20,40, 20,60, 20,80, LIGHTGRAY,1, 0,60, 20,60, 40,60, 60,60, LIGHTGRAY,0, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN,1以下是源代码:Game.h 文件#include #include #include #include #define UP w#define DOWN s#define LEFT a#define RIGHT d#define Esc 27int key=NULL;int a=0;st

4、ruct Shape int xy8; int color;struct full /记?录?每?个?方?块的?信?息 bool isfull; int color;Shape shape74= /7种?基本?形?状 四?种?变?形?(不?够?四?种?变?化的?用?相同?的?来填?充?)? 20,60, 20,40, 20,20, 40,60, RED, 0,60, 20,60, 40,40, 40,60, RED, 20,20, 40,20, 40,40, 40,60, RED, 0,60, 0,40, 20,40, 40,40, RED, , 20,60, 20,40, 20,20, 40

5、,20, YELLOW, 0,40, 0,60, 20,60, 40,60, YELLOW, 20,60, 40,60, 40,40, 40,20, YELLOW, 0,40, 20,40, 40,40, 40,60, YELLOW, , 0,60, 20,60, 20,40, 40,60, GREEN, 0,40, 20,60, 20,40, 20,20, GREEN, 0,40, 20,40, 20,60, 40,40, GREEN, 20,20, 20,40, 20,60, 40,40, GREEN, , 0,60, 20,60, 20,40, 40,40, WHITE, 0,40, 0

6、,20, 20,40, 20,60, WHITE, 0,60, 20,60, 20,40, 40,40, WHITE, 0,40, 0,20, 20,40, 20,60, WHITE , 0,40, 20,40, 20,60, 40,60 , BLUE, 0,40, 0,60, 20,40, 20,20 , BLUE, 0,40, 20,40, 20,60, 40,60 , BLUE, 0,40, 0,60, 20,40, 20,20 , BLUE, , 20,0, 20,20, 20,40, 20,60, LIGHTGRAY, 0,40, 20,40, 40,40, 60,40, LIGHT

7、GRAY, 20,0, 20,20, 20,40, 20,60, LIGHTGRAY, 0,40, 20,40, 40,40, 60,40, LIGHTGRAY, , 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, 20,40, 20,60, 40,40, 40,60, LIGHTGREEN, ;class Game int x,y; /x y 表示?方?块的?相对?坐?标 int dir; /方?块移?

8、动方?向 int _shape; /七?种?形?状 int change_shape; /四?种?变?换? int old_shape; /记?录?未变?形?方?块的?形?状 int old_change_shape; bool is_fullline20; /标记?是?否?满行D full isfull2010; /标记?是?否?有D方?块 20行D10列D public : Game(); int shapeX(int i)return (shape_shapechange_shape.xyi+x); /返回?shape形?状第i个?方?块的?的?实际X坐?标 int shapeY(int

9、 i)return (shape_shapechange_shape.xyi+1+y); /返回?shape形?状第i个?方?块的?的?实际Y坐?标 int rowX(int i)return i*20+100; /返回?第i列D的?X坐?标 int columnY(int i)return i*20+50; /返回?第i行D的?Y坐?标 void drawinterface(); /画-界?面? void drawshape(); /画-方?块 void clearshape(); /清?除y方?块 void drawshowshape( ); /画-在预览框中D的?方?块 void cle

10、arshowshape(); /清?除y在预览框中D的?方?块 void getdir(); /取?得?方?块移?动方?向 bool is_move_leftX(); /方?块是?否?能向左移? bool is_move_rightX(); /方?块是?否?能向右移? bool is_moveY(); /方?块是?否?能在 Y 轴方?向移?动 bool is_change(); /是?否?能变?形? (近边?界?时变?形?后不?能出?界?)? void shapemove(); /方?块移?动 void newshape(); /出?新?的?方?块 void fullline(); /扫描满行

11、D void clearfullline(); /清?除y满行D void repaint(); /重?画-(实现?消?行D下?移?)? bool isgameover(); /游?戏是?否?结束?;Game:Game () x=180; y=50; srand(unsigned)time(NULL); _shape=rand()%7; change_shape=rand()%4; for(int i=0;i20;i+) for(int j=0;j10;j+) isfullij.isfull =false; isfullij.color =BLACK; for(int i=0;i20;i+)

12、is_fulllinei=false; drawinterface();void Game:drawinterface () initgraph(640,480); rectangle(345,45,435,135); rectangle(95,45,305,455);void Game:drawshape () setfillstyle(shape_shapechange_shape.color ); for(int i=0;i=6;i+=2) bar(shapeX(i), shapeY(i), shapeX(i)+20, shapeY(i)+20);void Game:clearshape

13、 () setfillstyle(BLACK); for(int i=0;i=6;i+=2) bar(shapeX(i), shapeY(i), shapeX(i)+20, shapeY(i)+20);void Game:drawshowshape () setfillstyle(shapeold_shapeold_change_shape.color ); for(int i=0;i=6;i+=2) bar(shapeold_shapeold_change_shape.xy i+350,shapeold_shapeold_change_shape.xy i+1+50,shapeold_sha

14、peold_change_shape.xy i+350+20,shapeold_shapeold_change_shape.xy i+1+50+20);void Game:clearshowshape () setfillstyle(BLACK ); for(int i=0;i=6;i+=2) bar(shapeold_shapeold_change_shape.xy i+350,shapeold_shapeold_change_shape.xy i+1+50,shapeold_shapeold_change_shape.xy i+350+20,shapeold_shapeold_change

15、_shape.xy i+1+50+20);void Game:getdir() if(kbhit() dir=getch(); if(dir=27) key=dir;bool Game:is_move_leftX() for(int i=0;i=6;i+=2) if(shapeX(i)=100 |isfull(shapeY(i)-50)/20(shapeX(i)-100)/20-1.isfull =true )/ return false; return true;bool Game:is_move_rightX () for(int i=0;i=300|isfull(shapeY(i)-50

16、)/20(shapeX(i)-100)/20+1.isfull =true) / return false; return true;bool Game:is_moveY () for(int i=0;i=430 | isfull(shapeY(i)-50)/20+1(shapeX(i)-100)/20.isfull =true) / setcolor(RED); / rectangle(shapeX(i)-100)/20-1)*20+100,(shapeY(i)-50)/20+1)*20+50,(shapeX(i)-100)/20-1)*20+100+20,(shapeY(i)-50)/20

17、+1)*20+50+20); return false; return true;bool Game:is_change () for(int i=0;i=6;i+) if(change_shape3) if(shape_shapechange_shape+1.xy i+x300) /变?形?后超?出?边?界?不?能变? return false; if(isfull(shape_shapechange_shape+1.xyi+1+y-50)/20-1(shape_shapechange_shape+1.xyi+x-100)/20-1.isfull =true) /变?形?后碰?到?方?块 r

18、eturn false; else if(change_shape=3) if(shape_shape0.xy i+x300) return false; if(isfull(shape_shape0.xyi+1+y-50)/20-1(shape_shape0.xyi+x-100)/20-1.isfull =true) return false; return true;void Game:shapemove() if(a=0) old_shape=_shape; old_change_shape=change_shape; drawshowshape(); a=1; for(int i=0;

19、i20;i+) /把?一?秒?钟分?成20份Y (加快左右移?动的?速度)? drawshape(); getdir(); Sleep(50); clearshape(); switch(dir) case LEFT: if(is_move_leftX() ) x-=20; break; case RIGHT: if(is_move_rightX() ) x+=20; break; case DOWN: if(is_moveY() y+=20; break; case UP: if(is_change() change_shape+; if(change_shape=4) change_sha

20、pe=0; break; dir=NULL; if(is_moveY() y+=20; void Game:newshape () srand(unsigned)time(NULL); if(!is_moveY() clearshowshape(); a=0; drawshape(); for(int i=0;i=0;i-) for(int j=0;j10;j+) if(isfullij.isfull =true) count+; if(count=10) is_fulllinei=true; else is_fulllinei=false; count=0; void Game:clearf

21、ullline () for(int a=0;a=0;k-) if(is_fulllinek=true) for(int i=k;i0;i-) for(int j=0;j=0;i-) for(int j=0;j10;j+) setfillstyle(isfullij.color ); bar(j*20+100,i*20+50,j*20+120,i*20+70); bool Game:isgameover() for(int i=0;i=6;i+) if(shapeY(i)=50) return true; return false;Main.cpp 文件#include Game.hextern int key;Game game;int main() setwritemode(R2_XORPEN); while(key!=Esc) game.newshape(); game.shapemove (); if(game.isgameover () break; /game.repaint (); outtextxy(320,240,LGameOver); getch(); exit(0); closegraph(); return 0;

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

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