快速业务通道

用java编写的俄罗斯方块小游戏 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-20
; goff.setColor(textcolor2); goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2-1,height/2+9); goff.setColor(Color.white); goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2+10); s="使用向下的方向键实现下降"; goff.setColor(textcolor2); goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2-1,height/2+29); goff.setColor(Color.white); goff.drawString(s,barwidth+(width-fmsmall.stringWidth(s))/2,height/2+30); } screencount--; if(screencount<=0) { screencount=screendelay; showtitle=!showtitle; } } public void drawBars() { goff.setColor(barcolor); goff.fillRect(0,0,barwidth,blocksize*yblocks); goff.fillRect(barwidth+blocksize*xblocks,0,barwidth,blocksize*yblocks); goff.fillRect(0,blocksize*yblocks,xblocks*blocksize+2*barwidth,barwidth); } public boolean drawObject() { short i; boolean bottomreached=false; int x,y,checkx,checky; //清除旧图形 for(i=0;i<4;i++) { x=objectx+items[objectptr+i*2+objectrotation*itemrotlen]; y=objecty+items[objectptr+i*2+objectrotation*itemrotlen+1]; checkx=objectx+checks[objectptr+i*2+objectrotation*itemrotlen]; checky=objecty+checks[objectptr+i*2+objectrotation*itemrotlen+1]; if(y>=0) screendata[x][y]=0; if(screendata[checks][checky]!=0) bottomreached=true; } if(!bottomreached) { count--; if(count<=0||fast) { objecty++; count=curcount; } checkRotation(); objectdx=0; objectrotationd=0; } //绘制新图形 for(i=0;i<4;i++) { x=objectx+items[objectptr+i*2+objectrotation*itemrotlen]; y=objecty+items[objectptr+i*2+objectrotation*itemrotlen+1]; if(y>=0) screendata[x][y]=objectcolor; if(y>=(yblocks-1)) bottomreached=true; } if (bottomreached) { score++; newObject(); } return bottomreached; } public void checkRotation() { int dummyx; int dummyrot; int x,y; short i; boolean cando=true; dummyrot=(objectrotation+objectrotationd)%4; dummyx=objectx+objectdx; //确认该部分不会使屏幕旋转 for(i=0;i<4;i++) { x=dummyx+items[objectptr+i*2+dummyrot*itemrotlen]; if(x>=xblocks) dummyx-=(x-xblocks+1); else if(x<0) dummyx-=x; } for(i=0;(i<4&&cando);i++) { x=dummyx+items[objectptr+i*2+dummyrot*itemrotlen]; y=objecty+items[objectptr+i*2+dummyrot*itemrotlen+1]; if(y>=0) cando=cando&&(screendata[x][y]==0); if(y>=yblocks||x<0||x>=xblocks) cando=false; } if(cando) { objectrotation=dummyrot; objectx=dummyx; } } public void drawBlocks() { short x,y; for(x=0;x<xblocks;x++) { for(y=0;y<yblocks;y++) { goff.setColor(blocks[screendata[x][y]]); goff.drawRect(x*blocksize+barwidth,y*blocksize,blocksize-1,blocksize-1); goff.fillRect(x*blocksize+barwidth+3,y*blocksize+3,blocksize-6,blocksize-6); } } } public void checkFull() { short x,y; boolean found=false; for(y=yblocks-1;(y>=0&&!found);y--) { found=true; for(x=0;x<xblocks;x++) { if(screendata[x][y]==0) found=false; } if(found) { score+=10; //当用户的得分很多时,增加游戏速度 if(score>800) curcount=1; else if(score>600) curcount=2; else if(score>400) curcount=3; else if(score>200) curcount=

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号