自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(0)
  • 资源 (2)
  • 收藏
  • 关注

空空如也

软件设计师考试真题(2004-2011)

2004-2011年软件设计师考试真题以及答案

2012-05-22

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

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;i<height;i++) { image[i]=new unsigned char[width]; } bin->getImage(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);

2011-04-13

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除