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

📄 bullet.java

📁 本j2me坦克游戏是在Nokia平台下开发的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                                                SuperTank.canvas.mapOffsetY, tileW, tileW);                                            SuperTank.canvas.mapInfo[mapBlock] = 0;                                        }                                    }                                }                                else if (SuperTank.canvas.mapInfo[mapBlock] >=                                         4) {                                    SuperTank.canvas.gameLose = true;                                    SuperTank.canvas.overtimer.timeCounter = 0;                                    g.setColor(0x0);                                    homeover = true;                                    g.fillRect(SuperTank.canvas.mapOffsetX +                                               SuperTank.canvas.mapWidth / 2 - tileW*2,                                               SuperTank.canvas.mapOffsetY +                                               SuperTank.canvas.mapHeight - tileW*4, tileW*4,                                               tileW*4);                                }                                mapBlock++;                                if ( (mapBlock %                                      (SuperTank.canvas.mapWidth / tileW)) == 0)                                    break;                            }                            break;                        case 4: //down                            for (i = 0; i < 4; i++) {                                if ( (SuperTank.canvas.mapInfo[mapBlock] > 0) &&                                    (SuperTank.canvas.mapInfo[mapBlock] < 4)) {                                    if (SuperTank.canvas.mapInfo[mapBlock] == 2 &&                                        starNum != 3) {                                        ironPaint = true;                                     //   System.out.println(ironPaint);                                    }                                    if (SuperTank.canvas.mapInfo[mapBlock] != 2) {                                        blockY = mapBlock /                                            (SuperTank.canvas.mapWidth / tileW);                                        blockX = mapBlock -                                            blockY *                                            (SuperTank.canvas.mapWidth / tileW);                                        g.setColor(0x0);                                        g.fillRect(blockX * tileW +                                            SuperTank.canvas.mapOffsetX,                                            blockY * tileW +                                            SuperTank.canvas.mapOffsetY, tileW, tileW);                                        SuperTank.canvas.mapInfo[mapBlock] = 0;                                    }                                    else {                                        if (starNum == 3) {                                            blockY = mapBlock /                                                (SuperTank.canvas.mapWidth / tileW);                                            blockX = mapBlock -                                                blockY *                                                (SuperTank.canvas.mapWidth / tileW);                                            g.setColor(0x0);                                            g.fillRect(blockX * tileW +                                                SuperTank.canvas.mapOffsetX,                                                blockY * tileW +                                                SuperTank.canvas.mapOffsetY, tileW, tileW);                                            SuperTank.canvas.mapInfo[mapBlock] = 0;                                        }                                    }                                }                                else if (SuperTank.canvas.mapInfo[mapBlock] >=                                         4) {                                    SuperTank.canvas.gameLose = true;                                    SuperTank.canvas.overtimer.timeCounter = 0;                                    g.setColor(0x0);                                    homeover = true;                                    g.fillRect(SuperTank.canvas.mapOffsetX +                                               SuperTank.canvas.mapWidth / 2 - tileW*2,                                               SuperTank.canvas.mapOffsetY +                                               SuperTank.canvas.mapHeight - tileW*4, tileW*4,                                               tileW*4);                                }                                mapBlock++;                                if ( (mapBlock %                                      (SuperTank.canvas.mapWidth / tileW)) == 0)                                    break;                            }                        default:                            break;                    }                }                bombFlag = true;                bombCount = 4;                isbomb = true;            }        }		//explosion        if (bombFlag) {        	g.setColor(0);            g.fillRect(posX, posY, frameWidth + speed, frameHeight);            g.drawImage(bombImage, BposX, BposY, g.TOP | g.LEFT);            if (bombCount > 0) {                bombCount--;            }            else {            	g.setColor(0);                g.fillRect(BposX, BposY, bombImage.getWidth(),                           bombImage.getHeight());                bombFlag = false;                alive = false;                if(homeover){                    SuperTank.canvas.hero.paint(g);                    homeover = false;                }			}            //repaint the iron            if (ironPaint) {                SuperTank.canvas.reDraw(2,g);            }            if(grassPaint){                SuperTank.canvas.grassPaint = true;             //   SuperTank.canvas.reDraw(3,g);            }            return;        }        switch(direction) {            case 1:		//left                posX -= speed;                fillposX = posX + frameWidth;                fillposY = posY;                fillwidth = frameWidth +  speed;                fillheigh = frameHeight;                break;            case 2:		//right                posX += speed;                fillposX = posX - speed;                fillposY = posY;                fillwidth = frameWidth;                fillheigh = frameHeight;                break;            case 3:		//up                posY -= speed;                fillposX = posX;                fillposY = posY + speed;                fillwidth = frameWidth;                fillheigh = frameHeight;                break;            case 4:		//down                posY += speed;                fillposX = posX;                fillposY = posY - speed;                fillwidth = frameWidth;                fillheigh = frameHeight;            default:                break;        }        g.fillRect(fillposX, fillposY, fillwidth, fillheigh);//        DirectGraphics dg = DirectUtils.getDirectGraphics(g);        switch(direction & 0x0f) {            case 1:		//left//              dg.drawImage(drawBullet, posX, posY, g.TOP|g.LEFT, DirectGraphics.ROTATE_90);              g.drawImage(bulletLeft, posX, posY, g.TOP|g.LEFT);                break;            case 2:		//right//              dg.drawImage(drawBullet, posX, posY, g.TOP|g.LEFT, DirectGraphics.ROTATE_270);              g.drawImage(bulletRight, posX, posY, g.TOP|g.LEFT);                break;            case 3:		//up//              g.drawImage(drawBullet, posX, posY, g.TOP|g.LEFT);              g.drawImage(bulletUp, posX, posY, g.TOP|g.LEFT);                break;            case 4:		//down//              dg.drawImage(drawBullet, posX, posY, g.TOP|g.LEFT, DirectGraphics.ROTATE_180);              g.drawImage(bulletDown, posX, posY, g.TOP|g.LEFT);            default:                break;        }        if (grassPaint) {            SuperTank.canvas.grassPaint = true;         //   SuperTank.canvas.reDraw(3, g);        }   }   boolean ismapCollide() {       boolean collFlag = false;       boolean isContinue1 = true;	   boolean isContinue2 = true;       int collX, collY;       int i;       int tileW = SuperTank.canvas.tileW;       collX = posX - SuperTank.canvas.mapOffsetX;       collY = posY - SuperTank.canvas.mapOffsetY;       switch (direction & 0x0f) {           case 1: //left               collX = collX - tileW;               BposX = posX - bombImage.getWidth() / 2;               BposY = posY - bombImage.getHeight() / 2;               if (collX + tileW <= speed) {                   collFlag = true;                   mapBlock = 0x0ffff;                   BposX = SuperTank.canvas.mapOffsetX;                   posX = SuperTank.canvas.mapOffsetX;                   break;               }               else {                   collFlag = false;                   mapBlock = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) +                       collX / tileW;                   for (i = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) +                        collX / tileW;                        i <=                        ( (collY + frameHeight - 1) / tileW *                         (SuperTank.canvas.mapWidth / tileW) + collX / tileW + 1);                        i += (SuperTank.canvas.mapWidth / tileW)) {                       if (SuperTank.canvas.mapInfo[i] == 3) {                           grassPaint = true;                       }                       if (SuperTank.canvas.mapInfo[i] != 0 &&                           SuperTank.canvas.mapInfo[i] != 3) {                           collFlag = true;                           isContinue1 = false;                           break;                       }                   }                   if(starNum != 0 && speed > tileW && isContinue1){                       collX = collX - tileW;                       mapBlock = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) + collX / tileW;                   for (i = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) +                        collX / tileW;                        i <=                        ( (collY + frameHeight - 1) / tileW *                         (SuperTank.canvas.mapWidth / tileW) + collX / tileW + 1);                        i += (SuperTank.canvas.mapWidth / tileW)) {                        if (SuperTank.canvas.mapInfo[i] == 3) {                           grassPaint = true;                       }                       if (SuperTank.canvas.mapInfo[i] != 0 &&                           SuperTank.canvas.mapInfo[i] != 3) {                           collFlag = true;                    //       isContinue2 = false;                           break;                       }                   }                  /* if(starNum == 2 && (speed - tileW) >= tileW && isContinue2){                   	   collX = collX - tileW;                       mapBlock = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) + collX / tileW;                   for (i = (collY / tileW - 1) * (SuperTank.canvas.mapWidth / tileW) +                        collX / tileW;

⌨️ 快捷键说明

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