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

📄 hc.java

📁 一个类似打地鼠的j2me手机游戏。
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

import java.io.IOException;
import java.util.Random;
import javax.microedition.lcdui.*;

public class HC extends Canvas
{

    private static Random rand = new Random();
    private Mogura m1;
    private Mogura m2;
    private Mogura m3;
    private int ml;
    private int life;
    static int score;
    static int stnum;
    static boolean playSt;
    static boolean gameover;
    Image mmo;
    Image hg;

    public HC()
    {
        m1 = new Mogura(1);
        m2 = new Mogura(2);
        m3 = new Mogura(3);
        try
        {
            mmo = Image.createImage("/minimogu.png");
            hg = Image.createImage("/heart.png");
        }
        catch(IOException _ex) { }
    }

    public void hit(int i)
    {
        Mogura mogura = null;
        if(i == 1)
            mogura = m1;
        else
        if(i == 2)
            mogura = m2;
        else
            mogura = m3;
        if(mogura.returnMmove() <= 6 && mogura.returnMmove() > 1)
        {
            if(mogura.hanaSt())
            {
                if(score > 50)
                    score -= 50;
                life = life - 2;
                ml = ml + 2;
            } else
            {
                score += 10;
                ml--;
            }
            mogura.hit();
        }
    }

    public void init()
    {
        score = 0;
        stnum = 0;
        playSt = false;
    }

    public void keyPressed(int i)
    {
        int j = getGameAction(i);
        switch(j)
        {
        case 2: // '\002'
            hit(1);
            return;

        case 6: // '\006'
            hit(2);
            return;

        case 5: // '\005'
            hit(3);
            return;

        case 3: // '\003'
        case 4: // '\004'
        default:
            return;
        }
    }

    public synchronized void paint(Graphics g)
    {
        if(life < 1)
        {
            gameover = true;
            playSt = false;
        }
        if((rand.nextInt() >>> 1) % 100 < 40 && !m1.isMove())
            m1.start(stnum);
        if((rand.nextInt() >>> 1) % 100 < 40 && !m2.isMove())
            m2.start(stnum);
        if((rand.nextInt() >>> 1) % 100 < 40 && !m3.isMove())
            m3.start(stnum);
        g.setColor(0xffffff);
        g.fillRect(9, 4, 90, 40);
        m1.paint(g);
        m2.paint(g);
        m3.paint(g);
        if(m1.returnMmove() == 7 && !m1.hanaSt())
            life = life - 1;
        if(m2.returnMmove() == 7 && !m2.hanaSt())
            life = life - 1;
        if(m3.returnMmove() == 7 && !m3.hanaSt())
            life = life - 1;
        g.setColor(0);
        g.drawString("Score : " + score, 30, 5, 20);
        g.drawImage(hg, 10, 19, 20);
        g.drawString(" x " + life, 23, 19, 20);
        g.drawImage(mmo, 60, 19, 20);
        g.drawString(" x " + ml, 73, 19, 20);
        if(ml < 1)
            playSt = false;
    }

    public int returnH()
    {
        return life;
    }

    public int returnS()
    {
        return score;
    }

    public void startSet()
    {
        m1.init();
        m2.init();
        m3.init();
        ml = 20;
        life = 20;
        playSt = true;
        gameover = false;
    }

}

⌨️ 快捷键说明

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