用vc++编写的俄罗斯方块游戏

时间:2014-05-03 13:48:56
【文件属性】:

文件名称:用vc++编写的俄罗斯方块游戏

文件大小:3.57MB

文件格式:RAR

更新时间:2014-05-03 13:48:56

俄罗斯方块游戏

int CIBrick::shiftLeft (CBin*bin) { unsigned int posX; posX=getPosX(); posX=posX-1; setPosX(posX); if(checkCollision(bin)==0) { setPosX(posX+1); return 0; } return 1; } int CIBrick::shiftDown (CBin*bin) { unsigned int posY; posY=getPosY(); posY=posY+1; setPosY(posY); if (checkCollision(bin)==0) { setPosY(posY-1); return 0; } return 1; } int CIBrick::shiftRight (CBin*bin) { unsigned int posX; posX =getPosX(); posX=posX+1; setPosX(posX); if(checkCollision(bin)==0) { setPosX(posX-1); return 0; } return 1; } int CIBrick::rotateClockwise(CBin*bin) { unsigned int orientation,oldOrientation; orientation=getOrientation(); oldOrientation=orientation; if (orientation==3) orientation=0; else orientation=orientation+1; setOrientation(orientation); if(checkCollision(bin)==0) { setOrientation(oldOrientation); return 0; } return 1; } int CIBrick::checkCollision(CBin*bin) { unsigned int width; unsigned int height; unsigned char**image; unsigned int orientation; unsigned int posX; unsigned int posY; width=bin->getWidth(); height=bin->getHeight(); image=new unsigned char* [height]; for(unsigned int i=0;igetImage(image); orientation=getOrientation(); posX=getPosX(); posY=getPosY(); if (orientation==0) { if((posX+1<1)||(posX>width-1)||(posY<1)||(posY+2>height-1)) return 0; if((image[posY-1][posX]!=0)||(image[posY][posX]!=0)||(image[posY+1][posX]!=0)||(image[posY+2][posX]!=0)) return 0; } if(orientation==1) { if ((posX<2)||(posX+1>width-1)||(posY+1)<1||(posY>height-1)) return 0; if ((image[posY][posX-2]!=0)||(image[posY][posX-1]!=0)||(image[posY][posX]!=0)||(image[posY][posX+1]!=0)) return 0; } if (orientation==2) { if((posX+1<1)||(posX>width-1)||(posY<2)||(posY+1>height-1)) return 0; if ((image[posY-2][posX]!=0)||(image[posY-1][posX]!=0)||(image[posY][posX]!=0)||(image[posY+1][posX]!=0)) return 0; } if (orientation==3) { if ((posX<1)||(posX+2>width-1)||(posY+1<1)||(posY>height-1)) return 0; if ((image[posY][posX-1]!=0)||(image[posY][posX]!=0)||(image[posY][posX+1]!=0)||(image[posY][posX+2]!=0)) return 0; } return 1; } void CIBrick::operator>>(unsigned char** binImage) { unsigned int orientation ; unsigned int posX; unsigned int posY; unsigned char colour; posX=getPosX(); posY=getPosY(); orientation=getOrientation(); colour=getColour(); if(orientation==0) { binImage[posY-1][posX]=colour; binImage[posY][posX]=colour; binImage[posY+1][posX]=colour; binImage[posY+2][posX]=colour; } if(orientation==1) { binImage[posY][posX-2]=colour; binImage[posY][posX-1]=colour; binImage[posY][posX]=colour; binImage[posY][posX+1]=colour; } if (orientation==2) { binImage[posY-2][posX]=colour; binImage[posY-1][posX]=colour; binImage[posY][posX]=colour; binImage[posY+1][posX]=colour; } if (orientation==3) { binImage[posY][posX-1]=colour; binImage[posY][posX]=colour; binImage[posY][posX+1]=colour; binImage[posY][posX+2]=colour; } } void CIBrick::putAtTop(unsigned int newOrient,unsigned int newPosX) { setPosX(newPosX); setOrientation(newOrient); switch (newOrient) { case 0: setPosY(1);break; case 1: setPosY(0);break; case 2: setPosY(2);break; case 3: setPosY(0);break; } } int CLBrick::shiftLeft (CBin*bin) { unsigned int posX; posX=getPosX(); posX=posX-1; setPosX(posX);


【文件预览】:
NewTetris
----NewTetris.dsp(5KB)
----StdAfx.cpp(211B)
----resource.h(1019B)
----NewTetris.opt(53KB)
----NewTetrisView.h(3KB)
----NewTetris.aps(28KB)
----bin.h(817B)
----MainFrm.h(1KB)
----bin.cpp(2KB)
----NewTetrisDoc.cpp(2KB)
----Debug()
--------NewTetris.ilk(386KB)
--------NewTetris.bsc(3.06MB)
--------NewTetris.exe(152KB)
--------vc60.pdb(364KB)
--------NewTetris.sbr(0B)
--------MainFrm.sbr(0B)
--------NewTetris.res(7KB)
--------vc60.idb(217KB)
--------bin.obj(7KB)
--------NewTetris.pch(6.57MB)
--------NewTetrisView.obj(72KB)
--------NewTetris.obj(23KB)
--------NewTetrisDoc.obj(15KB)
--------bin.sbr(0B)
--------brick.sbr(0B)
--------MainFrm.obj(20KB)
--------StdAfx.obj(103KB)
--------NewTetrisView.sbr(0B)
--------brick.obj(58KB)
--------StdAfx.sbr(1.31MB)
--------NewTetrisDoc.sbr(0B)
--------NewTetris.pdb(505KB)
----NewTetris.cpp(4KB)
----ReadMe.txt(4KB)
----brick.cpp(24KB)
----NewTetris.dsw(541B)
----StdAfx.h(1KB)
----NewTetris.rc(11KB)
----NewTetris.ncb(321KB)
----NewTetrisView.cpp(15KB)
----MainFrm.cpp(2KB)
----NewTetris.h(1KB)
----NewTetris.clw(2KB)
----brick.h(3KB)
----res()
--------NewTetrisDoc.ico(1KB)
--------NewTetris.rc2(401B)
--------NewTetris.ico(1KB)
--------Toolbar.bmp(1KB)
----NewTetrisDoc.h(1KB)
----NewTetris.plg(252B)

网友评论

  • 为啥我用VC运行的时候老是提示我缺少什么文件库
  • 不错的新手入门资料
  • 入门还是可以的!
  • 运行效果很不错
  • 可以用,还行
  • 效果还是有的,学习中,谢咯
  • 操作有点延时!