快速业务通道

如何使用J2ME中的线程 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-19
=0;i Gridmatrix[i][0]=COLOR_DARK_GRAY; Gridmatrix[i][11]=COLOR_DARK_GRAY; } } /** Creates a new instance of TetrisCanvas */ public TetrisCanvas() { generator = new Random( System.currentTimeMillis() ); init(); Blocker = new Thread(this); Blocker.start(); } private void draw3DBlock(Graphics g, int c, int x, int y, int width, int height){ int color = g.getColor(); g.setColor( COLOR_WHITE ); g.drawRect( x, y, width, height ); g.setColor(c); g.fillRect( x + 1, y + 1, width-2, height-2 ); g.setColor( COLOR_BLACK ); g.drawLine( x + width-1, y, x + width-1, y + height-1 ); g.drawLine( x, y + height-1, x + width-1, y + height-1 ); g.setColor(color); } public static boolean drawText(Graphics g, String str, int x, int y, int anchor, int color, int size) { Font f_old,f_new; int c_old; try { f_old = g.getFont(); f_new = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_BOLD,size); g.setFont(f_new); c_old = g.getColor(); g.setColor(color); g.drawString(str, x, y, anchor ); g.setColor(c_old); g.setFont(f_old); return true; }catch (Exception ex) { return false; } } protected void paint(Graphics g){ //画背景 try{ Image image_Splash = Image.createImage("/back.png"); g.drawImage(image_Splash, 0, 0,Graphics.TOP | Graphics.LEFT); } catch(Exception ex) { } //画下一个要出现的方块 drawText(g, "下一个", 91, 5, Graphics.TOP| Graphics.LEFT, COLOR_BLUE, Font.SIZE_SMALL); g.setColor(COLOR_GRAY); g.drawRoundRect(91, 18, 26, 30, 2, 2); g.setColor(COLOR_DARK_GRAY); g.fillRoundRect(92, 19, 24, 28, 2, 2); for(int i=0;i<=3;i++) draw3DBlock(g, BlockInfo[FutureBlockType][8], 93+BlockInfo[FutureBlockType][i*2+1]*BLOCK_SIZE, 20+BlockInfo[FutureBlockType][i*2]*BLOCK_SIZE, BLOCK_SIZE,BLOCK_SIZE); drawText(g, "速度:"+String.valueOf(CurSpeed), 91, 60, Graphics.TOP| Graphics.LEFT, COLOR_BLUE, Font.SIZE_SMALL); drawText(g, "行数:"+String.valueOf(BlockLines), 91, 75, Graphics.TOP| Graphics.LEFT, COLOR_BLUE, Font.SIZE_SMALL); drawText(g, "成绩:", 91, 90, Graphics.TOP| Graphics.LEFT, COLOR_BLUE, Font.SIZE_SMALL); g.setColor(COLOR_GRAY); g.drawRoundRect(91, 105, 26, 20, 2, 2); g.setColor(COLOR_DARK_GRAY); g.fillRoundRect(92, 106, 24, 18, 2, 2); drawText(g, String.valueOf(BlockScore), 93, 107, Graphics.TOP| Graphics.LEFT, COLOR_WHITE, Font.SIZE_MEDIUM); //画当前战况 for(int i=0;i for(int j=1;j if (Gridmatrix[i][j]!=0) draw3DBlock(g,Gridmatrix[i][j],CANVAS_OFFSET_X+j*BLOCK_SIZE, CANVAS_OFFSET_Y+i*BLOCK_SIZE, BLOCK_SIZE,BLOCK_SIZE); if (!ISDOWN){ //画上新的方块 LastX=BlockX; LastY=BlockY; LastType=BlockType; for(int i=0;i<=3;i++) draw3DBlock(g,BlockInfo[BlockType][8], CANVAS_OFFSET_X+BlockX*BLOCK_SIZE+BlockInfo[BlockType][i*2+1]*BLOCK_SIZE, CANVAS_OFFSET_Y+BlockY*BLOCK_SIZE+BlockInfo[BlockType][i*2]*BLOCK_SIZE, BLOCK_SIZE,BLOCK_SIZE); } } private boolean feasible(){ for(int i=0;i<=3;i++) if (Gridmatrix[BlockY+BlockInfo[BlockType][i*2]][BlockX+BlockInfo[BlockType][i*2+1]]!=0) return false; return true; } private void delline(){ for(int i=0;i<=3;

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站: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号