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

📄 gamemain.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.*;
import java.util.Timer;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

public class GameMain
{

    public static final short START = 0;
    public static final short EXIT = 1;
    public static final short MENUVIEW = 2;
    public static final short INIT = 3;
    public static final short PAUSE = 4;
    private final NokiaGameEffects gameEffects = new NokiaGameEffects(this);
    Display display;
    RecordStore rec;
    GameMIDlet midlet;
    GameImageLoader gameImg;
    TitleCanvas titleCanvas;
    GameTimer gameTimer;
    GameCanvas gameCanvas;
    ScoreBoard scoreBoard;
    Loading loading;
    Timer timer;
    int stageScoreBoard[];
    int gameFlag;
    int totalScore;
    int firstScore;
    int secondScore;
    int thirdScore;
    int fourthScore;
    int fifthScore;
    int loadingCount;
    int screenSize;
    boolean soundFlag;
    boolean resumeFlag;
    int rank;

    public GameMain(Display display1, GameMIDlet gamemidlet)
    {
        display = display1;
        midlet = gamemidlet;
        soundFlag = true;
        timer = new Timer();
    }

    public int scoreCal()
    {
        if(totalScore > firstScore)
        {
            fifthScore = fourthScore;
            fourthScore = thirdScore;
            thirdScore = secondScore;
            secondScore = firstScore;
            firstScore = totalScore;
            return 1;
        }
        if(totalScore > secondScore)
        {
            fifthScore = fourthScore;
            fourthScore = thirdScore;
            thirdScore = secondScore;
            secondScore = totalScore;
            return 2;
        }
        if(totalScore > thirdScore)
        {
            fifthScore = fourthScore;
            fourthScore = thirdScore;
            thirdScore = totalScore;
            return 3;
        }
        if(totalScore > fourthScore)
        {
            fifthScore = fourthScore;
            fourthScore = totalScore;
            return 4;
        }
        if(totalScore > fifthScore)
        {
            fifthScore = totalScore;
            return 5;
        } else
        {
            return 0;
        }
    }

    private void openRMS()
    {
        try
        {
            if(rec == null)
                rec = RecordStore.openRecordStore("phoneshot", true);
        }
        catch(RecordStoreException recordstoreexception) { }
    }

    private void readRMS()
    {
        try
        {
            if(rec.getNumRecords() == 0)
            {
                firstScore = 0;
                secondScore = 0;
                thirdScore = 0;
                fourthScore = 0;
                fifthScore = 0;
                soundFlag = true;
            } else
            {
                ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(rec.getRecord(1));
                DataInputStream datainputstream = new DataInputStream(bytearrayinputstream);
                try
                {
                    firstScore = datainputstream.readInt();
                    secondScore = datainputstream.readInt();
                    thirdScore = datainputstream.readInt();
                    fourthScore = datainputstream.readInt();
                    fifthScore = datainputstream.readInt();
                    soundFlag = datainputstream.readBoolean();
                }
                catch(IOException ioexception) { }
            }
        }
        catch(RecordStoreException recordstoreexception) { }
    }

    void saveRMS()
    {
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
        try
        {
            dataoutputstream.writeInt(firstScore);
            dataoutputstream.writeInt(secondScore);
            dataoutputstream.writeInt(thirdScore);
            dataoutputstream.writeInt(fourthScore);
            dataoutputstream.writeInt(fifthScore);
            dataoutputstream.writeBoolean(soundFlag);
        }
        catch(IOException ioexception) { }
        byte abyte0[] = bytearrayoutputstream.toByteArray();
        try
        {
            if(rec.getNumRecords() == 0)
                rec.addRecord(abyte0, 0, abyte0.length);
            else
                rec.setRecord(1, abyte0, 0, abyte0.length);
        }
        catch(RecordStoreException recordstoreexception) { }
    }

    private void closeRMS()
    {
        try
        {
            if(rec != null)
                rec.closeRecordStore();
        }
        catch(RecordStoreException recordstoreexception) { }
    }

    public void gameControl()
    {
        switch(gameFlag)
        {
        default:
            break;

        case 3: // '\003'
            openRMS();
            readRMS();
            if(titleCanvas == null)
                titleCanvas = new TitleCanvas(this);
            display.setCurrent(titleCanvas);
            gameEffects.eachSound(14);
            break;

        case 1: // '\001'
            if(gameCanvas != null)
                gameCanvas = null;
            saveRMS();
            closeRMS();
            midlet.destroyApp(true);
            midlet.notifyDestroyed();
            break;
        }
    }
}

⌨️ 快捷键说明

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