欢迎来到天天文库
浏览记录
ID:8462212
大小:68.87 KB
页数:55页
时间:2018-03-28
《c++俄罗斯方块代码》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、Block.csusingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Drawing;usingSystem.Windows.Forms;namespaceTetris{//////砖Á?块¨¦的Ì?类¤¨¤///classBlock{protectedPoint[]structArr;//储ä¡é存ä?砖Á?块¨¦组Á¨¦成¨¦信?息
2、¡é的Ì?坐Á?标À¨º数ºy组Á¨¦protectedint_xPos;//研D究?砖Á?块¨¦顶£¤点Ì?所¨´在¨²游®?戏¡¤界?面?的Ì?x坐Á?标À¨ºprotectedint_yPos;//研D究?砖Á?块¨¦顶£¤点Ì?所¨´在¨²游®?戏¡¤界?面?的Ì?y坐Á?标À¨ºprotectedColor_blockColor;//砖Á?块¨¦的Ì?颜?色¦?protectedColor_disapperColor;//擦¨¢出?颜?色¦?protectedintrectPix;//每
3、?个?单Ì£¤元a格?的Ì?像?素?publicBlock()//默?认¨?构1造¨¬函¡¥数ºy,ê?声¦¨´明¡Â此ä?函¡¥数ºy是º?为a了¢?子Á¨®类¤¨¤能¨¹顺3利¤?创ä¡ä建¡§{}///Block类¤¨¤的Ì?构1造¨¬函¡¥数ºy的Ì?介¨¦绍¦¨¹///Block类¤¨¤的Ì?构1造¨¬函¡¥数ºy//////储ä¡é存ä?砖Á?块¨¦各¡Â点Ì?的Ì?Point类¤¨¤///4、mname="bColor">砖Á?块¨¦颜?色¦?///擦¨¢出?颜?色¦?///砖Á?块¨¦像?素?publicBlock(Point[]sa,ColorbColor,ColordColor,intpix){_blockColor=bColor;_disapperColor=dColor;rectPix=pix;structArr=sa;}publicPointthis[i5、ntindex]{get{returnstructArr[index];}}#region成¨¦员¡À变À?量¢?相¨¤应®6、属º?性?publicintLengce{get{returnstructArr.Length;}}publicintxPos{get{return_xPos;}set{_xPos=value;}}publicintyPos{get{return_yPos;}set{_yPos=value;}}publicColorBlockColor{get{return_blockCo7、lor;}}#endregionpublicvoidDeasilRotate()//顺3时º¡À针?旋y转Áa{inttemp;for(inti=0;i8、+i){temp=structArr[i].X;structArr[i].X=-structArr[i].Y;structArr[i].Y=temp;}}privateRectanglePointToRect(Pointp){returnnewRectangle((_xPos+p.X)*rectPix+1,(_yPos-p.Y)*rectPix+1,rectPix-2,rectPix-2);}//////在¨²指?定¡§画-板ã?下?绘?制?砖Á?块¨¦///9、///一°?个?用®?于®¨²绘?制?的Ì?Graphics对?象¨®publicvirtualvoidPaint(Graphicsgp){SolidBrushsb=newSolidBrush(_blockColor);foreach(PointpinstructArr){lock(gp)//线?程¨¬锁?{gp.FillRectangle(sb,PointToRect(p));}}}publicvoiderase(Graphicsg
4、mname="bColor">砖Á?块¨¦颜?色¦?///擦¨¢出?颜?色¦?///砖Á?块¨¦像?素?publicBlock(Point[]sa,ColorbColor,ColordColor,intpix){_blockColor=bColor;_disapperColor=dColor;rectPix=pix;structArr=sa;}publicPointthis[i
5、ntindex]{get{returnstructArr[index];}}#region成¨¦员¡À变À?量¢?相¨¤应®
6、属º?性?publicintLengce{get{returnstructArr.Length;}}publicintxPos{get{return_xPos;}set{_xPos=value;}}publicintyPos{get{return_yPos;}set{_yPos=value;}}publicColorBlockColor{get{return_blockCo
7、lor;}}#endregionpublicvoidDeasilRotate()//顺3时º¡À针?旋y转Áa{inttemp;for(inti=0;i8、+i){temp=structArr[i].X;structArr[i].X=-structArr[i].Y;structArr[i].Y=temp;}}privateRectanglePointToRect(Pointp){returnnewRectangle((_xPos+p.X)*rectPix+1,(_yPos-p.Y)*rectPix+1,rectPix-2,rectPix-2);}//////在¨²指?定¡§画-板ã?下?绘?制?砖Á?块¨¦///9、///一°?个?用®?于®¨²绘?制?的Ì?Graphics对?象¨®publicvirtualvoidPaint(Graphicsgp){SolidBrushsb=newSolidBrush(_blockColor);foreach(PointpinstructArr){lock(gp)//线?程¨¬锁?{gp.FillRectangle(sb,PointToRect(p));}}}publicvoiderase(Graphicsg
8、+i){temp=structArr[i].X;structArr[i].X=-structArr[i].Y;structArr[i].Y=temp;}}privateRectanglePointToRect(Pointp){returnnewRectangle((_xPos+p.X)*rectPix+1,(_yPos-p.Y)*rectPix+1,rectPix-2,rectPix-2);}//////在¨²指?定¡§画-板ã?下?绘?制?砖Á?块¨¦///
9、///一°?个?用®?于®¨²绘?制?的Ì?Graphics对?象¨®publicvirtualvoidPaint(Graphicsgp){SolidBrushsb=newSolidBrush(_blockColor);foreach(PointpinstructArr){lock(gp)//线?程¨¬锁?{gp.FillRectangle(sb,PointToRect(p));}}}publicvoiderase(Graphicsg
此文档下载收益归作者所有