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

📄 maincanvas.java

📁 J2me月光战机游戏源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import java.io.*;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;
// download by http://www.codefans.net
public class MainCanvas extends Canvas
    implements Runnable, CommandListener
{   
    static int MainFlag = 0;
    static int ThreadSpeed = 100;
    static int ReadCount = 0;
    static int ik = 0;
    static int gk = 0;
    static boolean FlgSoftKey1 = false;
    static boolean FlgSoftKey2 = false;
    static boolean FlgPushDecide = false;
    static boolean FlgPushUp = false;
    static boolean FlgPushDown = false;
    static boolean FlgPushLeft = false;
    static boolean FlgPushRight = false;
    static int LogoCount = 0;
    static int TitleCount = 0;
    static int ClearWait = 0;
    static int Cursor = 0;
    static int BackMain = 0;
    static String StrHelpMenu[] = null;
    InputStream is;
    public static Command toggleCommand;
    public static Command exitCommand;
    static String SoftMess1 = "";
    static String SoftMess2 = "";
    RecordStore rs;
    static int rsId = 0;
    static Image offImage = null;
    static Graphics offGfx = null;
    static Image imgTitle;
    static Image imgMyShip;
    static Image imgIcon[] = new Image[4];
    static Image imgFace[] = new Image[2];
    static Image imgEye[] = new Image[2];
    static Image imgEnemy[] = new Image[7];
    static Image imgBoss[] = new Image[22];
    static Image imgMyShot[] = new Image[15];
    static Image imgEShot[] = new Image[10];
    static Image imgBomb[] = new Image[4];
    static Image imgStar[] = new Image[4];
    static boolean PlayerAlive = true;
    static int PlayerBomb = 0;
    static int PlayerX;
    static int PlayerY;
    static int PlayerXSp;
    static int PlayerYSp;
    static int PAttackMode;
    static int PAttackMain;
    static int Muteki = 0;
    static int MySpecialCount = 0;
    static int MyChar;
    static int ShotWait;
    static int AnimMyLazer;
    static int MyLazerLength;
    static boolean MyShotAlive[] = new boolean[30];
    static int MyShotType[] = new int[30];
    static int MyShotX[] = new int[30];
    static int MyShotY[] = new int[30];
    static int MyShotMX[] = new int[30];
    static int MyShotMY[] = new int[30];
    static int EnemyWait;
    static int EnemyType[] = new int[20];
    static boolean EnemyAlive[] = new boolean[20];
    static int EnemyLife[] = new int[20];
    static int EnemyX[] = new int[20];
    static int EnemyY[] = new int[20];
    static int EnemyXSize[] = new int[20];
    static int EnemyYSize[] = new int[20];
    static int EnemyFlag1[] = new int[20];
    static int EnemyFlag2[] = new int[20];
    static int EnemyBomb[] = new int[20];
    static int EnemyPoint[] = new int[20];
    static int BossWait = 0;
    static int BossType[] = new int[5];
    static boolean BossAlive[] = new boolean[5];
    static boolean BossDamage[] = new boolean[5];
    static int BossMaxLife = 0;
    static int BossLife[] = new int[5];
    static int BossX[] = new int[5];
    static int BossY[] = new int[5];
    static int BossXSize[] = new int[5];
    static int BossYSize[] = new int[5];
    static int BossFlag1[] = new int[5];
    static int BossFlag2[] = new int[5];
    static int BossFlag3[] = new int[5];
    static int BossFlag4[] = new int[5];
    static int BossBomb[] = new int[5];
    static int BossPoint[] = new int[5];
    static boolean BossTarget;
    static int BossTargetX;
    static int BossTargetY;
    static boolean EShotAlive[] = new boolean[100];
    static int EShotType[] = new int[100];
    static int EShotX[] = new int[100];
    static int EShotY[] = new int[100];
    static int EShotMX[] = new int[100];
    static int EShotMY[] = new int[100];
    static int EShotFlag[] = new int[100];
    static int StarType[] = new int[10];
    static int StarX[] = new int[10];
    static int StarY[] = new int[10];
    static int EncountType[] = new int[5];
    static int EncountNumber = 0;
    static boolean FlgOption[] = new boolean[3];
    static int Round = 1;
    static int Stage = 1;
    static int Score = 0;
    static int HiScore = 0;
    static int ExtendPoint = 0;
    static int BonusTotal = 0;
    static int BonusPoint = 0;
    static int BonusEnemy = 0;
    static int BonusEscape = 0;
    static int Rest = 3;
    static int MyLife = 5;
    static boolean GameClear = false;
    static boolean FlgGameOver = false;
    static int FlgBoss = 0;
    static int MapScroll = 0;
    static int StartCount = 0;
    static int ExtendCount = 0;
    static int OverCount = 0;
    static int HelpPage = 0;
    static int Path[] = new int[2];


    public MainCanvas(Display display1, moonlight moonlight1)
    {
        display = null;
        thread = null;
        god = new Random();
        SCREEN_WH = SCREEN_W / 2;
        is = null;
        rs = null;
        boolean flag = false;
        app = moonlight1;
        display = display1;
        try
        {
            boolean flag1 = false;
            Object obj = null;
            Object obj1 = null;
        }
        catch(Exception exception) { }
        offImage = Image.createImage(SCREEN_W, SCREEN_H);
        offGfx = offImage.getGraphics();
        DataLoad();
        for(int i = 0; i < FlgOption.length; i++)
            FlgOption[i] = true;

        thread = new Thread(this);
        thread.start();
        SetSoftKey();
    }

    public void paint(Graphics g)
    {
        Graphics g1 = g;
        g = offGfx;
        offGfx = g1;
    }

    public void run()
    {
        long l = 0L;
        do
        {
            try
            {
                Thread.yield();
                try
                {
                    if(System.currentTimeMillis() - l >= (long)ThreadSpeed)
                    {
                        l = System.currentTimeMillis();
                        AutoEvent();
                        ScanKey();
                        DrawGraphic();
                        repaint();
                        System.gc();
                    }
                }
                catch(Exception exception) { }
            }
            catch(Exception exception1)
            {
                return;
            }
            
        } while(true);
    }

    public void commandAction(Command command, Displayable displayable)
    {
    }

    public void AutoEvent()
    {
        boolean flag = false;
        boolean flag1 = false;
        switch(MainFlag)
        {
        case 2: // '\002'
        case 3: // '\003'
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
        case 9: // '\t'
        case 10: // '\n'
        case 11: // '\013'
        case 12: // '\f'
        default:
            break;

        case 0: // '\0'
            try
            {
                Object obj = null;
                if(ReadCount != 0)
                    if(ReadCount >= 1 && ReadCount < 16)
                    {
                        if(ReadCount == 1)
                            is = getClass().getResourceAsStream("tshot");
                        int i = ReadCount - 1;
                        byte abyte0[] = new byte[SHOT_SIZE[i]];
                        is.read(abyte0);
                        imgMyShot[i] = Image.createImage(abyte0, 0, abyte0.length);
                        abyte0 = null;
                        System.gc();
                        if(ReadCount == 15)
                            is.close();
                    } else
                    {
                        imgTitle = Image.createImage("/title.png");
                        imgMyShip = Image.createImage("/jiki.png");
                        for(int i10 = 0; i10 < 4; i10++)
                            imgIcon[i10] = Image.createImage("/icon" + i10 + ".png");

                        for(int j10 = 0; j10 < 2; j10++)
                        {
                            imgFace[j10] = Image.createImage("/face" + j10 + ".png");
                            imgEye[j10] = Image.createImage("/eye" + j10 + ".png");
                        }

                        for(int k10 = 0; k10 < 7; k10++)
                            imgEnemy[k10] = Image.createImage("/z" + k10 + ".png");

                        for(int l10 = 0; l10 < 10; l10++)
                            imgEShot[l10] = Image.createImage("/eshot" + l10 + ".png");

                        for(int i11 = 0; i11 < 4; i11++)
                            imgBomb[i11] = Image.createImage("/bomb" + i11 + ".png");

                        for(int j11 = 0; j11 < 4; j11++)
                            imgStar[j11] = Image.createImage("/star" + j11 + ".png");

                        ChangeMain(2);
                    }
                ReadCount++;
            }
            catch(Exception exception) { }
            break;

⌨️ 快捷键说明

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