c++怎么实现俄罗斯方块

  介绍

小编给大家分享一下c++怎么实现俄罗斯方块,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获、下面让我们一起去了解一下吧!

具体内容如下

工具:vc + + 2010,图库:EasyX

先看效果图片

 C + +怎么实现俄罗斯方块

纯手写,没有面向对象思想,看全部源码

# include  & lt; stdio.h>   # include  & lt; graphics.h>   # include  & lt; time.h>   # include  & lt; conio.h>      # define  BLOCK_COUNT  5   # define  BLOCK_WIDTH  5   # define  BLOCK_HEIGHT  5   # define  UNIT_SIZE  20   # define  START_X  130年      # define  START_Y  30   # define  KEY_UP  72年   # define  KEY_RIGHT  77年   # define  KEY_LEFT  75年   # define  KEY_SPACE  32   # define  KEY_DOWN  76年   enum {typedef    BLOCK_UP,   BLOCK_RIGHT,   BLOCK_DOWN,大敌;   ,BLOCK_LEFT   }block_dir_t;   enum {typedef    MOVE_DOWN,   MOVE_LEFT,   ,MOVE_RIGHT      }move_dir_t;   int  speed =, 500;   int  NextIndex =, 1;//下一个方块种类   int  BlockIndex =, 1;//当前方块种类   int  score =, 0;//分数   int  rank =, 0;//等级   int 访问[30][15];//访问数组   int  markcolor[30][15];//表示颜色   int  minX =, 30;   int  minY =, 30;   int 颜色(BLOCK_COUNT)={   ,绿色,青色,品红色,棕色,黄色   };   int 块[BLOCK_COUNT * 4] [BLOCK_HEIGHT] [BLOCK_WIDTH],=, {   ,//条形方块   ,{   ,0,0,0,0,0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,0,0,   ,0,1,1,- 1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,0,0,   ,0,1,1,- 1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,//L形方块   ,{   ,0,0,0,0,0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,1,1,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,0,0,   ,0,1,1,- 1,0,   ,0 1 0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0,0,1 0 0,   ,0,0,1 0 0,   ,0,0,0,0,0},,   ,{   ,0,0,0,0,0,   ,0,0,0,1,0,   ,0,1,1,- 1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},,   ,//田字型   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0 1 1 0 0,   ,0,0,0,0,0,   ,0,0,0,0,0},,   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0 1 1 0 0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0 1 1 0 0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0 1 1 0 0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,//T字形方块   ,{   ,0,0,0,0,0,   ,0,1,1,- 1,0,   ,0,0,1 0 0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,1,0,   ,0,0,1,1,0,   ,0,0,0,1,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,1 0 0,   ,0,1,1,- 1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,1 0 0,   ,0,0,1,1,0,   ,0,0,1 0 0,   ,0,0,0,0,0},   ,//Z字形方块   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0,0,1,1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,1,0,   ,0,0,1,1,0,   ,0,0,1 0 0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0 1 1 0 0,   ,0,0,1,1,0,   ,0,0,0,0,0,   ,0,0,0,0,0},   ,{   ,0,0,0,0,0,   ,0,0,0,1,0,   ,0,0,1,1,0,   ,0,0,1 0 0,   ,0,0,0,0,0}   };//欢迎界面   void 欢迎(){   ,//初始化画布   ,initgraph (550660);      ,//设置窗口标题   ,HWND  window =, GetHWnd();//获取窗口   ,SetWindowText(窗口,_T(“俄罗斯方块,GWF"));//设置窗口标题         ,//设置文本字体样式   _T, setfont(0, 30日(“微软雅黑“));   ,改变颜色(黄色);   150200年,outtextxy (_T(“俄罗斯方块“));   ,setfont (0 10 _T(“微软雅黑“));   ,outtextxy(175300年,_T(“它编程从俄罗斯方块开始“));   ,睡眠(3000);   ,   }//初始化游戏屏幕   void  initGameScene () {   ,char  str [16];   ,//清除屏幕   ,清除设备();      27336635年,矩形(27日);   29334633年,矩形(29日);   ,矩形(370、50515195);   0,setfont(24日,_T(“楷体“));   ,改变颜色(浅灰色);   405215年,outtextxy (_T(“下一个“));   ,改变颜色(红色);   405280年,outtextxy (_T(“分数“));   ,sprintf (str,“% d",分数);   415310年,outtextxy (str);   405375年,outtextxy (_T(“等级“));   ,sprintf (str,“% d",排名);   415405年,outtextxy (str);   ,改变颜色(LIGHTBLUE);   ,outtextxy(390475年,“操作说明“);   ,outtextxy(390500年,“↑:旋转“);   ,outtextxy(390525年,“↓:下降“);   ,outtextxy(390550年,“→:向右“);   ,outtextxy(390575年,“←:向左“);   ,outtextxy(390600年,“空格:暂停“);            }   int  void  drawBlock (int  x, y){//右上角画出方块   (NextIndex),改变颜色(颜色);   0,setfont(23日,“楷体“);   ,(int 我=,0;i< BLOCK_HEIGHT;我+ +){   ,(int  j=, 0; j

c++怎么实现俄罗斯方块