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

📄 bombjackscreen.java

📁 一个很不错的炸弹人J2ME游戏源码.画面及音效质量都不错,可供新手学习使用.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// 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 bombjack;

import gamelib.GameObject;
import gamelib.GameScreen;
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.VolumeControl;
import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordStore;

// Referenced classes of package bombjack:
//            Enemy, Platform, Bomb, ImageLoader, 
//            Player, BombJack

public class BombJackScreen extends GameScreen
    implements CommandListener
{

    public static final String CHEAT_LIVES = "667626";
    public static final String CHEAT_SKIP = "783556";
    private byte currentMenu;
    public static boolean doVibrate = true;
    public static boolean doSound = true;
    public static final boolean FULLCLEAR = true;
    boolean fullRate;
    public static final int DOUBLECLICK = 320;
    public static final int HOVERCLICK = 500;
    public static int FRAMERATE = 18;
    public static int EXTRALIFEAT = 0x208dc;
    public static int BONUSAT = 5000;
    public static final int PAUSE_MODE = -1;
    public static final int GAME_MODE = 1;
    public static final int GAMEOVER_MODE = 2;
    public static final int NEXTLEVEL_MODE = 3;
    public static final int DIE_MODE = 4;
    public static final int WAIT_MODE = 10;
    public static final int START_MODE = 11;
    public static final int ABOUT_MODE = 12;
    public static final int HISCORE_MODE = 13;
    public static final int ENTER_HISCORE_MODE = 14;
    public static final int MESSAGE_MODE = 22;
    public static final int CONTROL_CHOOSE_MODE = 15;
    public static final int EXIT_MODE = 23;
    public static final int MENU_MODE = 50;
    private static final int PRESSED = 1;
    private static final int RELEASED = 0;
    public static int SCORE_BOMB = 1;
    public static int SCORE_ENEMY = 2;
    public static int START_ANIM_TIME = 25;
    public static int END_ANIM_TIME = 50;
    private byte charPos;
    private byte playerNamePos;
    private String playerName[] = {
        "_", "_", "_", "_", "_", "_", "_", "_"
    };
    private String scoreChars;
    private Font fontB;
    private Font fontM;
    private Font fontSB;
    private int actionAnimCount;
    private int logoAnimCount;
    private int currentKey;
    private int currentKeyState;
    public boolean bRunning;
    public boolean livesCheat;
    public static boolean firstPaint = true;
    public byte currentLevel;
    public int gameMode;
    public int oldGameMode;
    private byte otherEnemyType;
    private Image gameScreen;
    private Image statusScreen;
    private Image scoreImg;
    private Image bombCollect;
    private Image enemyCollect;
    private Image otherEnemy;
    private Image logo;
    private Image eemo;
    private Image elite;
    private Image hiscores;
    private long time;
    protected static BombJack parent = null;
    private boolean doPaint;
    private boolean chooseEndGame;
    private boolean invincible;
    private Bomb currentBomb;
    private Random random;
    private int oldScrollX;
    private int oldScrollY;
    public int hoverCounter;
    public int doHover;
    public int lastDir;
    public int curDir;
    private long lastFire;
    private int colortab[];
    public static final int COL_NONE = 0;
    public static final int COL_LEFT = 1;
    public static final int COL_RIGHT = 16;
    public static final int COL_TOP = 256;
    public static final int COL_BOTTOM = 4096;
    public static final int COL_ON_PF = 0x10000;
    public static final int COL_SKY = 0x100000;
    public static final int COL_GROUND = 0x1000000;
    private byte playfield[][];
    private short enemymap[][];
    private Enemy enemies[];
    private Enemy powerball;
    private Enemy bonuscoin;
    private Enemy extracoin;
    private Bomb bombs[];
    private byte robotFactories[];
    private int scorePos[][];
    private int aboutPointer;
    private int aboutScroll;
    private int scores[];
    private String scoreNames[];
    private RecordStore storage;
    private String displayText[];
    private Image border;
    public static final Command commandExit = new Command("EXIT", 7, 1);
    public static final Command commandBack = new Command("BACK", 7, 1);
    public static final Command commandPause = new Command("PAUSE", 3, 1);
    public static final Command commandYes = new Command("YES", 4, 1);
    public static final Command commandNo = new Command("NO", 3, 1);
    public static final Command commandOK = new Command("OK", 4, 1);
    public static final Command commandCancel = new Command("CANCEL", 3, 1);
    public String currentString;
    private Graphics statusGraphics;
    public static Player musicPlayer;
    public static Player sndStart;
    public static Player sndDead;
    public static Player sndGameover;
    public static Player sndLevelfinish;
    Thread updateThread;
    int smc;
    int fcl;
    public int zaehler;
    public int sync;

    private Player loadSound(String s, String s1, boolean flag)
    {
        Player player = null;
        try
        {
            InputStream inputstream = getClass().getResourceAsStream(s);
            if(inputstream == null)
                inputstream = getClass().getResourceAsStream("/" + s);
            player = Manager.createPlayer(inputstream, s1);
            player.realize();
            player.setLoopCount(flag ? -1 : 1);
        }
        catch(Exception exception) { }
        return player;
    }

    protected static void stopSound(Player player)
    {
        try
        {
            player.stop();
        }
        catch(Exception exception) { }
        try
        {
            player.deallocate();
        }
        catch(Exception exception1) { }
    }

    protected static void playSound(Player player)
    {
        Player aplayer[] = {
            musicPlayer, sndStart, sndDead, sndGameover, sndLevelfinish
        };
        for(int i = 0; i < aplayer.length; i++)
            stopSound(aplayer[i]);

        if(!doSound)
            return;
        try
        {
            player.prefetch();
        }
        catch(Exception exception) { }
        try
        {
            player.setMediaTime(0L);
        }
        catch(Exception exception1) { }
        try
        {
            player.start();
        }
        catch(Exception exception2) { }
    }

    public BombJackScreen(BombJack bombjack)
    {
        currentMenu = 0;
        fullRate = false;
        charPos = 0;
        playerNamePos = 0;
        scoreChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-*.1234567890<";
        actionAnimCount = 0;
        logoAnimCount = 0;
        currentKeyState = 0;
        currentLevel = 0;
        gameMode = -1;
        doPaint = false;
        chooseEndGame = false;
        invincible = false;
        currentBomb = null;
        random = new Random();
        oldScrollX = 999;
        oldScrollY = 999;
        doHover = 0;
        lastDir = -1;
        curDir = -2;
        lastFire = 0L;
        playfield = new byte[26][34];
        enemymap = new short[26][34];
        scorePos = new int[15][];
        scores = new int[10];
        scoreNames = new String[10];
        currentString = "";
        updateThread = null;
        smc = 0;
        fcl = 0;
        zaehler = 0;
        sync = 2;
        parent = bombjack;
        doPaint = false;
    }

    private void init()
    {
        gameMode = 10;
        repaint();
        serviceRepaints();
        ImageLoader.init();
        musicPlayer = loadSound("ingame.mid", "audio/midi", true);
        sndStart = loadSound("start.wav", "audio/x-wav", false);
        sndDead = loadSound("dead.wav", "audio/x-wav", false);
        sndGameover = loadSound("gameover.wav", "audio/x-wav", false);
        sndLevelfinish = loadSound("level_finished.wav", "audio/x-wav", false);
        colortab = (new int[] {
            0xffff00, 0xffff40, 0xffff80, 0xffffc0, 0xffffe0, 0xffffff, 0xffe0e0, 0xffc0c0, 0xff8080, 0xff4040, 
            0xff2020, 0xff0000, 0xff2020, 0xff0040, 0xff0080, 0xff00c0, 0xff00e0, 0xff00ff, 0xe000ff, 0xc000ff, 
            0x8000ff, 0x4000ff, 0x2000ff, 255, 0x2020e0, 0x404080, 0x808060, 0xc0c040, 0xe0e020
        });
        fontB = Font.getFont(64, 1, 16);
        fontM = Font.getFont(64, 0, 16);
        fontSB = Font.getFont(64, 1, 0);
        border = Image.createImage(getWidth(), getHeight());
        Graphics g = border.getGraphics();
        g.setColor(0);
        g.fillRect(0, 0, getWidth(), getHeight());
        for(int i = 0; i < 7; i++)
        {
            g.setColor(Platform.palette1[i]);
            g.drawLine(i, i, getWidth() - i, i);
            g.drawLine(i, getHeight() - i, getWidth() - i, getHeight() - i);
            g.drawLine(getWidth() - i, i, getWidth() - i, getHeight() - i);
            g.drawLine(i, i, i, getHeight() - i);
        }

        try
        {
            scoreImg = ImageLoader.getImage(10);
            bombCollect = ImageLoader.getImage(0);
            enemyCollect = ImageLoader.getImage(4);
            storage = RecordStore.openRecordStore("highscores", true);
            buildLocalScores();
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        System.gc();
        firstPaint = true;
        showMenu();
        setCommandListener(this);
        setCommands();
    }

    public void close()
    {
        bRunning = false;
        try
        {
            Thread.currentThread();
            Thread.sleep(300L);
            updateThread = null;
        }
        catch(Exception exception) { }
    }

    public void show()
    {
        if(updateThread == null)
        {
            updateThread = new Thread(this);
            updateThread.start();
        }
    }

    public final int getLocalPos(int i)
    {
        int j = 0;
        for(j = 0; j < scores.length && i <= scores[j]; j++);
        if(j == scores.length)
            return -1;
        else
            return j;
    }

    public final void storeLocalScore(int i, String s)
    {
        int j = getLocalPos(i);
        if(j >= 0)
        {
            for(int k = scores.length - 1; k > j; k--)
            {
                scores[k] = scores[k - 1];
                scoreNames[k] = scoreNames[k - 1];
            }

            scores[j] = i;
            scoreNames[j] = s;
            saveScores();
        }
    }

    private final void saveScores()
    {
        try
        {
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(256);
            DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
            dataoutputstream.writeBoolean(doVibrate);
            dataoutputstream.writeBoolean(doSound);
            for(int i = 0; i < scores.length; i++)
            {
                dataoutputstream.writeInt(scores[i]);
                dataoutputstream.writeUTF(scoreNames[i]);
            }

            byte abyte0[] = bytearrayoutputstream.toByteArray();
            try
            {
                storage.setRecord(1, abyte0, 0, abyte0.length);
            }
            catch(InvalidRecordIDException invalidrecordidexception)
            {
                storage.addRecord(abyte0, 0, abyte0.length);
            }
            catch(Exception exception1) { }
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private static final String encode(String s)
    {
        StringBuffer stringbuffer = new StringBuffer();
        for(int i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == ',' || c == '.' || c == '-' || c == '_')
            {
                stringbuffer.append(c);
                continue;
            }
            if(c == ' ')
            {
                stringbuffer.append('+');
            } else
            {
                stringbuffer.append('%');
                stringbuffer.append(Integer.toHexString(c));
            }
        }

        return stringbuffer.toString();
    }

    public final void buildLocalScores()
    {
        try
        {
            DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(storage.getRecord(1)));
            doVibrate = datainputstream.readBoolean();
            doSound = datainputstream.readBoolean();
            for(int i = 0; i < scores.length; i++)
            {

⌨️ 快捷键说明

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