bonus.java

来自「JVAV手机游戏坦克游戏源程序下载 那都可以5下地的。希望你们支持好吗?」· Java 代码 · 共 96 行

JAVA
96
字号
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Bonus
{
    public static Graphics g = null;
    private Image bonus;
    private Image imgTimer;
    private Image imgPower;
    private Image imgBomber;
    private Image imgWall;
    private Image imgTanker;
    private Image imgCap;
    private Image imgBlock;
    public int bonusKind;
    public int bonusX;
    public int bonusY;
    public int formerBonusX;
    public int formerBonusY;
    public int bonusWidth;
    public int bonusHeight;
    int count = 1;
    public Bonus()
    {
        bonusKind = 0;
        bonusX =  - 1;
        bonusY =  - 1;
        formerBonusX =  - 1;
        formerBonusY =  - 1;
        try
        {
            bonus = Image.createImage("/bonus.png");
            bonusWidth = bonus.getWidth() / 3;
            bonusHeight = bonus.getHeight() / 2;
            imgBomber = Image.createImage(bonusWidth, bonusHeight);
            g = imgBomber.getGraphics();
            g.drawImage(bonus, 0, 0, g.TOP | g.LEFT);
            imgPower = Image.createImage(bonusWidth, bonusHeight);
            g = imgPower.getGraphics();
            g.drawImage(bonus,  - bonusWidth, 0, g.TOP | g.LEFT);
            imgTanker = Image.createImage(bonusWidth, bonusHeight);
            g = imgTanker.getGraphics();
            g.drawImage(bonus,  - bonusWidth * 2, 0, g.TOP | g.LEFT);
            imgTimer = Image.createImage(bonusWidth, bonusHeight);
            g = imgTimer.getGraphics();
            g.drawImage(bonus, 0,  - bonusHeight, g.TOP | g.LEFT);
            imgWall = Image.createImage(bonusWidth, bonusHeight);
            g = imgWall.getGraphics();
            g.drawImage(bonus,  - bonusWidth,  - bonusHeight, g.TOP | g.LEFT);
            imgCap = Image.createImage(bonusWidth, bonusHeight);
            g = imgCap.getGraphics();
            g.drawImage(bonus,  - bonusWidth * 2,  - bonusHeight, g.TOP | g.LEFT); //g.TOP|g.LEFT:g.topleft
            imgBlock = Image.createImage("/back.png");
        }
        catch (Exception exception)
        {
            System.out.println(exception);
        }
    }
    synchronized void paint(Graphics g)
    {
        if (count % 3 != 0)
        {
            switch (bonusKind)
            {
                case 1:
                    g.drawImage(imgTimer, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                case 2:
                    g.drawImage(imgPower, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                case 3:
                    g.drawImage(imgBomber, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                case 4:
                    g.drawImage(imgWall, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                case 5:
                    g.drawImage(imgTanker, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                case 6:
                    g.drawImage(imgCap, bonusX, bonusY, g.TOP | g.LEFT);
                    break;
                default:
                    break;
            }
        }
        else
        {
            g.drawImage(imgBlock, bonusX, bonusY, g.TOP | g.LEFT);
            count = 0;
        }
        count++;
    }
}

⌨️ 快捷键说明

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