C++俄罗斯方块代码(北邮版)

上传人:博****1 文档编号:487027764 上传时间:2023-07-09 格式:DOCX 页数:12 大小:52.09KB
返回 下载 相关 举报
C++俄罗斯方块代码(北邮版)_第1页
第1页 / 共12页
C++俄罗斯方块代码(北邮版)_第2页
第2页 / 共12页
C++俄罗斯方块代码(北邮版)_第3页
第3页 / 共12页
C++俄罗斯方块代码(北邮版)_第4页
第4页 / 共12页
C++俄罗斯方块代码(北邮版)_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《C++俄罗斯方块代码(北邮版)》由会员分享,可在线阅读,更多相关《C++俄罗斯方块代码(北邮版)(12页珍藏版)》请在金锄头文库上搜索。

1、#include #include #include #include #include #include colorConsole.h /老师的文件void begin(); /开始游戏void frame(); /边框设定int * getblocks(); /方块产生void move(int line); /移动void drawblocks(int line); /方块显示void clearsquare(int line); /方块擦出void turn(int line); /方块旋转bool isavailable(int line); /判断是否能下落void remembe

2、r(int line); /记忆方块位置void deleteline(int line); /方块满一行消除bool ifgameover(); /判断是否游戏结束void end(); /游戏结束 #define up 72#define down 80#define left 75#define right 77#define esc 27HANDLE handle;int a144=1,1,1,1; /七种方块的二维数组int a244=0,1,1,1,1;int a344=1,1,0,1,1;int a444=0,0,1,1,1,1;int a544=0,1,1,1,1;int a6

3、44=1,1,1,1;int a744=1,1,1,1;int row=0; /列数int score=0;int level=0;int * block1=NULL; int * block2=NULL;int * block3=NULL;int coordinate1218=0; /坐标数组,边框12*18(最后一行,两边边框计算在内)int judge=0;推荐精选int scorex=0;int temp44=0;void main() /主函数 int t=1;handle = initiate();while(t)t=0; begin(); sndPlaySound(music.w

4、av,SND_LOOP|SND_ASYNC); frame(); WORD wColors1; wColors0=FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY; for(int k=1;k=999999;k+)if(ifgameover() /判断是否结束 textout(handle,34,10,wColors,1,Game Over); Sleep(800); end(); else if(k=1)block2=getblocks();block3=block2; /block2指向将出现的方块地址block2=getblocks

5、(); /获取下一个新的方块block1=block3; row=52; clearsquare(16); /擦除next的方块block1=block2;drawblocks(15); /在next显示下一块方块图形row=34;block1=block3;for(int i=4;i=7;i+) /所构建的方块图形最多只有占有两排,所以只用4-7即可对应 if(*(block1+i)textout(handle,26+i*2,4,wColors,1,); /方块先露出下面部分Sleep(500-50*level);推荐精选for(int line=4;line=22;line+) /方块自主

6、下落,方块从第四排开始出现if(isavailable(line) /检验刚产生的方块是否碰壁,碰到已落方块clearsquare(line); /消除方块先露初的下面分drawblocks(line); /产生完整的下落方块move(line);elseremember(line); /落定后将这些位置对应的all数组中元素置1deleteline(line); /消行以及加分if(line=4)judge=1;break;void begin()int i=1;WORD wColors1;wColors0=FOREGROUND_GREEN|FOREGROUND_INTENSITY;WORD

7、 wColors12;wColors10=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY; wColors11=FOREGROUND_RED|FOREGROUND_INTENSITY;textout(handle,18,4,wColors,1, );textout(handle,18,5,wColors,1, );textout(handle,18,6,wColors,1,);textout(handle,18,7,wColors,1,);textout(handle,18,8,wColors,1, );textout(handle,1

8、8,9,wColors,1,);textout(handle,18,10,wColors,1,);推荐精选textout(handle,18,11,wColors,1,);textout(handle,18,12,wColors,1,);textout(handle,18,13,wColors,1,);textout(handle,18,14,wColors,1,);textout(handle,18,15,wColors,1, );textout(handle,18,16,wColors,1, 简单 中等);textout(handle,18,17,wColors,1,请按1 请按2);te

9、xtout(handle,18,18,wColors,1, );textout(handle,18,19,wColors,1, );textout(handle,18,20,wColors,1, 困难 请按 3); textout(handle,54,22,wColors,1,MADE BY );while(i)textout(handle,30,8,wColors1,2,俄罗斯方块);Sleep(800);textout(handle,30,8,wColors1,2, ); Sleep(800); if (_kbhit() /输入等级switch(_getch()case 1: level=

10、1;i=0; /跳出循环break;case 2: level=4;i=0;break;case 3: level=7;i=0;break;system(cls); /清屏推荐精选void frame() /边框的设定WORD wColors1;wColors0=FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY;WORD wColors11;wColors10=FOREGROUND_RED|FOREGROUND_INTENSITY;for(int i=0;i=11;i+)coordinatei17=1; /底排边框定义为1for(int j=0;j=17;j+)coordinate0j=1; /两边边框定义为1coordinate11j=1;char string5;textout(handle,59,5,wColors,1,itoa(level,string,10); textout(handle,52,5,wColors,1,level: );textout(handle,52,9,wColors

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 资格认证/考试 > 自考

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号