⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ictankcanvas.java.bak

📁 本j2me坦克游戏是在Nokia平台下开发的
💻 BAK
📖 第 1 页 / 共 5 页
字号:
                }

                break;

            //add here to tell the story
            case 5:
                g.setColor(0x0);
                g.fillRect(0,0,width,height);
                g.setColor(0xffffff);
	            g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
	            g.drawString("选项", width-fontWidth, height-fontHeight, 20);
                gameSubStatus +=2;
            case 6:



 /*           case 9:

                ictimer.timeCounter = 0;
                gameStatus = 2;
                gameSubStatus = 1;
            default:
                break;
        }*/

       //switch(gameSubStatus) {
         /*   case 1:
				if ( ictimer.timeCounter < 2 ){

			        try {
			            t_logo = Image.createImage("/logo.png");

						g.setColor(0xffffff);
						g.fillRect(0, 0, width, height);
			        } catch (IOException ioexception) { ioexception.printStackTrace();}

					g.drawImage(t_logo, (width-t_logo.getWidth())/2, (height-t_logo.getHeight())/2, g.TOP|g.LEFT);

				} else {

	                if ( firstTime ){
	                    g.setColor(0xffffff);
	                    g.fillRect(0, 0, width, height);
	                    t_logo = null;
	                    firstTime = false;
	                }
	                g.translate((width-ic.getWidth())/2, ((height-ic.getHeight()-logo.getHeight())/2+logo.getHeight()) );

	                g.setClip(0, 0, title_w, ic.getHeight());
	                g.drawImage(ic, 0, 0, g.TOP|g.LEFT);
	                if ( title_w < ic.getWidth() ){
					//	System.out.println("ic.getWidth()=" +ic.getWidth());
						title_w += 8;
					}else {
	                    gameSubStatus ++;
	                    ictimer.timeCounter = 0;
	                    title_h = 0;
	                }
	            }
                break;*/

            case 7:
                //if ( ictimer.timeCounter < 2 )
                //    g.drawImage(logo, (width-logo.getWidth())/2, (height-ic.getHeight()-logo.getHeight())/2, g.TOP|g.LEFT);
                //else{
                    g.setColor(0x0);
                    g.fillRect(0,0,width,height);
                    g.setColor(0xffffff);
	                g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
	                g.drawString("选项", width-fontWidth, height-fontHeight, 20);
                 //   g.fillRect(0, 0, width, title_h);

                 //   g.fillRect(0, height-title_h, width, title_h);

                 //   if ( title_h <= (height/2 ))
                 //       title_h += 4;
                 //   else {
                        //ic = null;
                        //logo = null;
                        // Load the title image
                        try {
                            ic = Image.createImage("/tank_e.png");
                        }
                        catch(Exception exception) {
                            System.out.println(exception);
                        }
                        gameSubStatus ++;
                //    }
                    fadeCol = 0x0;
                //}
                break;
            case 8:
                g.setColor(fadeCol, fadeCol, fadeCol);
                g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_BOLD, Font.SIZE_MEDIUM));
                g.drawString("敌人来了......", width/2, (height-ic.getHeight()-fontHeight)/2-3, g.TOP|g.HCENTER);

                if ( fadeCol < 0xfc )
                    fadeCol += 4;
                else {
                    ictimer.timeCounter = 0;
                    gameSubStatus ++;
                    ictimer.timeCounter = 0;
                    title_y = ic.getHeight()/2 ;
                    title_h = 0;
                }

                break;
            case 9:
                g.setColor(0xffffff);
                g.fillRect(0, (height+fontHeight)/2-title_h, width, title_h*2);

                if ( title_h < (ic.getHeight()/2) ){
                    title_h += 2;
                }
                else {
                    gameSubStatus ++;
                    title_x = -ic.getWidth();
                }
                break;

            case 10:
                g.setColor(0xffffff);
                g.fillRect(0, ((height-ic.getHeight()+fontHeight)/2), width, ic.getHeight() );
                g.drawImage(ic, title_x, ((height-ic.getHeight()+fontHeight)/2), g.TOP|g.LEFT);

                if ( title_x < 0 ){
                    title_x += 1;
                }
                else {
//                    title = null;
                    gameSubStatus ++;
                    ictimer.timeCounter = 0;
                    // Load the title image
                    try {
                        title = Image.createImage("/tank_a.png");
                    }
                    catch(Exception exception) {
                        System.out.println(exception);
                    }
                    title_x = width + title.getWidth();
                }

                break;

            case 11:
                g.setColor(0xffffff);
                g.fillRect(0, ((height-ic.getHeight()+fontHeight)/2), width, title.getHeight() );
                g.drawImage(ic, 0, ((height-ic.getHeight()+fontHeight)/2), g.TOP|g.LEFT);
                g.drawImage(title, title_x, ((height-title.getHeight()+fontHeight)/2), g.TOP|g.LEFT);

                if ( title_x >= (width - title.getWidth()) ){
                    title_x -= 2;
                }
                else {
                    gameSubStatus ++;
                    ictimer.timeCounter = 0;
                    g.setColor(0x00);
                    g.fillRect(0, 0, width, ((height-title.getHeight()+fontHeight)/2-1));
                }
                break;

            case 12:
                g.setColor(0xff, 0xff, 0xfe);
                g.setColor(fadeCol, fadeCol, fadeCol);
                g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_BOLD, Font.SIZE_MEDIUM));
                g.drawString("我们迎战吧!", width/2, (height-title.getHeight()-fontHeight)/2-3, g.TOP|g.HCENTER);

                if ( ictimer.timeCounter >= 2 ){
                    if ( fadeCol > 0 )
                        fadeCol -= 4;
                    else {
                        title_h = 0;
                        ictimer.timeCounter = 0;
                        gameSubStatus +=2;
                        ictimer.timeCounter = 0;
                    }
                }
                break;

            case 13:

           /* case 14:
                if ( ictimer.timeCounter >= 2 ){
                    g.setColor(0x0);
                    g.fillRect(0, (height-title.getHeight())/2, width, title_h);

                    g.fillRect(0, ((height+title.getHeight())/2+fontHeight-title_h), width, title_h);

                    if ( title_h <= (title.getHeight()/2) ){
                        title_h += 5;
                    }
                    else {
                        title = null;
                        gameSubStatus ++;
                    }
                }
                break;*/

            case 14:
                if ( ictimer.timeCounter >= 1 ){
                    logo = null;
                    ic = null;
                    ictimer.timeCounter = 0;
                    gameStatus = 2;
                    gameSubStatus = 1;
                }
            default:
                break;
        }
    }

    private void introPaint(Graphics g) {
        int i, j, lev;
        boolean samePas = false;

       switch(gameSubStatus) {
            case 1:
                // Load the title image
                try {
                    title = Image.createImage("/title.png");
                }
                catch(Exception exception) {
                    System.out.println(exception);
                }
                gameSubStatus ++;
                //Test
                g.setColor(0x0);
                g.fillRect(0, 0, width, height);
                //Test
                title_y = title.getHeight()/2 ;
                title_h = 0;
                break;

            case 2:
                g.setColor(0xffffff);
                g.fillRect(0, (height-title.getHeight())/6+title_y, (width-title.getWidth())/2, title_h);
                g.fillRect((width+title.getWidth())/2, (height-title.getHeight())/6+title_y, (width-title.getWidth())/2, title_h);

                g.translate((width-title.getWidth())/2, (height-title.getHeight())/6);
                g.setClip(0, title_y, title.getWidth(), title_h);

                g.drawImage(title, 0, 0, g.TOP|g.LEFT);

                if ( title_h < title.getHeight() ){
                    title_y -= 2;
                    title_h += 4;
                }
                else {
                    gameSubStatus ++;
                    ictimer.timeCounter = 0;
                }
                break;



            case 3:
                g.drawImage(title, (width-title.getWidth())/2, (height-title.getHeight())/6, g.TOP|g.LEFT);

                g.setColor(0x00, 0x00, 0x00);
                g.fillRect(width/2-50, (height-title.getHeight())/3+title.getHeight(), 100, fontHeight*3 );
                switch(gameSelect) {
                    case 1:
                        g.setColor(0xfe, 0x3f, 0x00);
                        g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_BOLD, Font.SIZE_MEDIUM));
                        g.drawString("游戏开始", width/2, (height-title.getHeight())/3+title.getHeight(), g.TOP|g.HCENTER);

                        g.setColor(0x00, 0xfe, 0xfe);
                        g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
                        g.drawString("继续游戏", width/2, (height-title.getHeight())/3+title.getHeight()+fontHeight, g.TOP|g.HCENTER);

                        break;
                    case 2:
                        g.setColor(0x00, 0xfe, 0xfe);
                        g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_PLAIN, Font.SIZE_MEDIUM));
                        g.drawString("游戏开始", width/2, (height-title.getHeight())/3+title.getHeight(), g.TOP|g.HCENTER);

                        g.setColor(0xfe, 0x3f, 0x00);
                        g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_BOLD, Font.SIZE_MEDIUM));
                        g.drawString("继续游戏", width/2, (height-title.getHeight())/3+title.getHeight()+fontHeight, g.TOP|g.HCENTER);

                    default:
                        break;
                }
               break;

            case 4:// New  game
                g.setColor(0x0);
                g.fillRect(0, 0, width, height);

                level = 1;
                life = 3;
                initLevel();
                setLevel(level);
                gameStatus = 3;
                gameSubStatus = 1;

                break;

            case 5:// password
                g.setColor(0x0);
                g.fillRect(0, 0, width, height);

				// Load the title image
				try {
					title= null;
					logo = Image.createImage("/bg_t.png");
					ic = Image.createImage(160, 140);
		            G = ic.getGraphics();
					for ( i = 0; i < (160/logo.getWidth()); i ++ )
						for ( j = 0; j < (140/logo.getHeight()); j ++ )
				            G.drawImage(logo, i*logo.getWidth(), j*logo.getHeight(), 20);

					logo = null;
				    G = null;
				}
				catch (Exception exception) {
					System.out.println(exception);
				}

				g.drawImage(ic, (width-ic.getWidth())/2, (height-ic.getHeight())/2, g.TOP | g.LEFT);

	            for ( i  = 0; i < 3; i ++ ){
					g.setColor(0x7f+i*0x40, 0x7f+i*0x40, 0x7f+i*0x40);
	               // g.drawRect( 15+i, 12+height/3+i, width-20-i*2, height/4-i*2);
                          g.drawRect( 45+i, 15+height/3+i, width-90-i*2, height/4-3-i*2);
	            }

                g.setColor(0);
                g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_BOLD, Font.SIZE_MEDIUM));
                g.drawString("输入你的过关密码", width/2, height/4, g.TOP|g.HCENTER);
                password[0] = 'A';
                password[1] = 'A';
                password[2] = 'A';
                password[3] = 'A';
                passPos = 1;
                gameSubStatus ++;

                break;

            case 6:
				g.setClip(width/2-40, height/2, 80, fontHeight);
				g.drawImage(ic, (width-ic.getWidth())/2, (height-ic.getHeight())/2, g.TOP | g.LEFT);

                g.setColor(0x00, 0x00, 0xff);
                g.setFont(Font.getFont(Font. FACE_PROPORTIONAL,  Font.STYLE_PLAIN, Font.SIZE_SMALL));

                if ( passPos == 1)
                    g.setColor(0xfe, 0x3f, 0x00);
                else
                    g.setColor(0xff, 0xff, 0xfe);

                g.drawString("" + password[0], width/2-20, height/2, g.TOP|g.HCENTER);

                if ( passPos == 2)
                    g.setColor(0xfe, 0x3f, 0x00);
                else
                    g.setColor(0xff, 0xff, 0xfe);

                g.drawString("" + password[1], width/2-10, height/2, g.TOP|g.HCENTER);

                if ( passPos == 3)
                    g.setColor(0xfe, 0x3f, 0x00);
                else
                    g.setColor(0xff, 0xff, 0xfe);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -