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

📄 diver.java

📁 一款j2me的钓鱼游戏,大家可以自由设计鱼.可以部署在eclipse,netbeans.
💻 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 

package org.cesar.inmotion.sea.basic;

import java.io.PrintStream;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import org.cesar.inmotion.sea.*;
import org.cesar.inmotion.util.GameItem;

// Referenced classes of package org.cesar.inmotion.sea.basic:
//            Fire, Fish

public class Diver extends GameItem
{

    private final byte STEP = 2;
    private short img_col;
    private short img_lin;
    public boolean repeatLeft;
    public boolean repeatRight;
    public boolean repeatDown;
    public boolean repeatUp;
    public boolean atSurface;
    private Fire fire;
    private byte fishcount;
    public int breath;

    public Diver(Image image)
    {
        super(0, 0, image);
        atSurface = true;
        breath = 1000;
        setVisible(true);
        setXspeed(3);
        setYspeed(3);
        fire = new Fire((short)0, (short)0, true, null);
        fire();
        init();
    }

    public void init()
    {
        setY(GameCanvas.SurfaceY - 5);
        setX(GameCanvas.ScreenWidth / 2 - getImage().getWidth() / 2);
        setImage(Constants.img_diver_surface[img_col]);
        atSurface = true;
    }

    public void update()
    {
        fire.setY(getY() + 7);
        if(atSurface)
        {
            if(breath < 985)
            {
                breath += 15;
            } else
            {
                breath = 1000;
                if(fishcount < 6)
                    Constants.score += fishcount * 2;
                else
                    Constants.score += fishcount * 10 + breath / 100;
                fishcount = 0;
            }
        } else
        {
            if(!fire.isVisible())
                fire();
            if(breath < 2)
                breath = 0;
            else
                breath -= 2;
            if(breath == 0)
            {
                GameCanvas.getInstance().die();
                breath = 1000;
            }
        }
        if(repeatLeft && getX() > 0)
        {
            setX(getX() - getXspeed());
            img_col = 0;
        }
        if(repeatRight && getX() < GameCanvas.ScreenWidth - getImage().getWidth())
        {
            setX(getX() + getXspeed());
            img_col = 1;
        }
        if(repeatDown && (!atSurface || atSurface && getFishcount() == 0) && getY() < GameCanvas.ScreenHeight - 10)
            setY(getY() + getYspeed());
        if(repeatUp)
            if(getY() > GameCanvas.SurfaceY - 5)
            {
                setY(getY() - getYspeed());
            } else
            {
                setImage(Constants.img_diver_surface[img_col]);
                if(!atSurface)
                {
                    atSurface = true;
                    if(getFishcount() == 0 && breath < 1000)
                        GameCanvas.getInstance().die();
                }
            }
        if(getY() > GameCanvas.SurfaceY)
        {
            atSurface = false;
            if(breath < 300 && GameCanvas.frame % 10 <= 5)
                setImage(Constants.img_diver_blowing);
            else
                setImage(Constants.img_diver[img_col][img_lin]);
            if(GameCanvas.frame % 10 == 5)
                img_lin = (short)(++img_lin % 4);
        }
        processIntersection();
    }

    private void processIntersection()
    {
        for(byte byte0 = 0; byte0 < GameCanvas.attack.getSharkCount(); byte0++)
        {
            Fish fish = GameCanvas.attack.getShark(byte0);
            Fish fish1 = GameCanvas.attack.getFish(byte0);
            if(fish.isVisible() && !fish.isDead() && intersects(fish))
            {
                fish.kill();
                fish.setVisible(false);
                System.out.println("Ops!");
                GameCanvas.getInstance().die();
            }
            if(fishcount < 6 && fish1.isVisible() && !fish1.isDead() && intersects(fish1))
            {
                fish1.kill();
                fish1.setVisible(false);
                System.out.println("Gotcha!");
                if(fishcount < 6)
                    fishcount++;
            }
        }

    }

    public void draw(Graphics g)
    {
    }

    public void fire()
    {
        fire.setY((short)getY() + 7);
        if(img_col == 1)
        {
            fire.setImage(Constants.img_fire[1]);
            fire.setXspeed((short)(-Math.abs(fire.getXspeed())));
            fire.setX((short)getX() + getImage().getWidth());
        } else
        {
            fire.setImage(Constants.img_fire[0]);
            fire.setXspeed((short)Math.abs(fire.getXspeed()));
            fire.setX((short)getX());
        }
        fire.setVisible(true);
    }

    public byte getFishcount()
    {
        return fishcount;
    }

    public void setFishcount(byte byte0)
    {
        fishcount = byte0;
    }

    public Fire getFire()
    {
        return fire;
    }
}

⌨️ 快捷键说明

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