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

📄 gamecanvas.java

📁 一款一个益智类的手机游戏源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package rescuenew;

import com.nokia.mid.sound.Sound;
import com.nokia.mid.ui.DeviceControl;
import com.nokia.mid.ui.FullCanvas;
import java.io.InputStream;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import java.util.*;

public class GameCanvas extends FullCanvas implements Runnable
{
    private byte status;
    public void run()
    {
        while (true)
        {
            try
            {
                Thread.sleep(threadTime);
            }
            catch (InterruptedException interruptedexception)
            {}
            if (10000 > timeCount)
            {
                timeCount++;
            }
            repaint();
        }
    }

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

    private Thread paintThread = null;
    //------------------------------------
    private Image digifunLogo;
    private Image mobilLogo;
    private int timeCount;
    public boolean sendscore = false;
    private int y3 = 25;
    //------------------------------------
    private static boolean blSound;
    private final int WIDTH = getWidth();
    private final int HEIGHT = getHeight();
    private final int half_width;
    private final int half_height;
    private final byte LOGO = 0;
    private final byte MENU = 1;
    private final byte GAME = 2;
    private final byte CONTINUE = 3;
    private final byte KEYHELP = 4;
    private final byte ENV = 5;
    private final byte RANKING = 6;
    private final byte QUESTION = 7;
    private final byte EXIT = 8;
    private final byte START = 0;
    private final byte PLAY = 1;
    private final int menuLoc[][] =
        {
        {
        0, 0, 43, 19
    }
        ,
        {
        1, 28, 15, 13
    }
        ,
        {
        27, 19, 22, 14
    }
        ,
        {
        10, 19, 17, 9
    }
        ,
        {
        1, 19, 9, 7
    }
        ,
        {
        28, 33, 12, 8, 44, 30
    }
        ,
        {
        16, 33, 12, 8, 44, 30
    }
        ,
        {
        0, 0, 130, 23
    }
    };
    private final byte envLoc[][] =
        {
        {
        0, 0, 55, 19, 0, 0
    }
        ,
        {
        15, 20, 11, 9, -34, -16
    }
        ,
        {
        0, 19, 14, 14, 19, -16
    }
        ,
        {
        26, 19, 10, 10, 11, 10
    }
        ,
        {
        36, 19, 10, 10, 29, 10
    }
        ,
        {
        15, 29, 14, 9, -46, 13
    }
        ,
        {
        29, 30, 12, 6, -25, 16
    }
        ,
        {
        46, 19, 7, 7, -43, 4
    }
    };
    private final byte cloud[][] =
        {
        {
        1, 61, 1, 2, 3
    }
        ,
        {
        33, 73, 1, 2, 5
    }
        ,
        {
        41, 45, 0, 1, 7
    }
        ,
        {
        93, 77, 2, 3, 4
    }
    };
    private final byte imgNum[] =
        {
        1, 6, 9, 9, 1, 1, 0, 1, 0
    };

    private RescueGame midlet;
    private Image img[];
    private Image backBufferImg;
    private byte Main_Mode;
    private byte Sub_Mode;
    private int threadTime;
    private byte imgCount;
    private byte aniCount;
    private int menu_start;
    private int menu_target;
    private int env_target;
    private int method_target;
    private int method;
    private int story_start;
    private int info_start;
    private boolean isLightOn;
    private boolean acceptKey;
    private static int oldSound = -1;
    private static int volume = 1;
    int selected019Menu;
    private boolean isPause;
    private Manager gm;
    private static int soundSize[] =
        {
        57, 62, 30, 20, 23, 21, 21, 43, 37, 24,
        23, 36, 39, 64, 22, 24
    };
    private static Sound sound = null;
    public GameCanvas(RescueGame midlet1)
    {
        this.midlet = midlet1;

        half_width = WIDTH / 2;
        half_height = HEIGHT / 2;
        try
        {
            digifunLogo = Image.createImage("/dfzlogo.png"); //mobilLogo.png
            mobilLogo = Image.createImage("/mobilLogo.png");
        }
        catch (Exception e)
        {
            digifunLogo = null;
        }
        inIt();
    }

    private void inIt()
    {
        blSound = true;
        img = new Image[9];
        threadTime = 250;
        aniCount = 0;
        menu_start = 0;
        menu_target = 0;
        env_target = 0;
        method_target = 1;
        method = 0;
        story_start = 0;
        info_start = 0;
        isLightOn = true;
        acceptKey = false;
        selected019Menu = 0;
        isPause = false;
        System.gc();
        timeCount = 0;
        setMenuMode( (byte) 0);
        installSound();
        gm = new Manager(WIDTH, HEIGHT);
        System.gc();
        start();

        DeviceControl.flashLights(0L);
        backLightOnOff();
    }

    private void setSubMode(byte byte0)
    {
        Sub_Mode = byte0;
    }

    private void setMenuMode(byte byte0)
    {
        Main_Mode = byte0;
        setSubMode( (byte) 0);
        imgCount = 0;
        acceptKey = false;
    }

    private void setThreadTime(int i)
    {
        threadTime = i;
    }

    private void drawDFZLogo(Graphics g)
    {
        g.drawImage(digifunLogo, 0, 0, 20);
    }

    private void drawMobilLogo(Graphics g)
    {
        g.drawImage(mobilLogo, 0, 0, 20);
    }

    public void paint(Graphics g)
    {
        if (timeCount <= 6)
        {
            g.setColor(255, 255, 255);
            g.fillRect(0, 0, WIDTH, HEIGHT);
            drawMobilLogo(g);
            return;
        }
        if (timeCount > 6 && timeCount <= 12)
        {
            g.setColor(255, 255, 255);
            g.fillRect(0, 0, WIDTH, HEIGHT);
            drawDFZLogo(g);
            return;
        }
        if (timeCount == 13)
        {
            mobilLogo = digifunLogo = null;
            System.gc();
        }
        if (timeCount == 5)
        {
            playSound("/title.ott", 0, 0);
            if (sound != null)
            {
                volume = sound.getGain() == 0 ? 0 : 1;
            }
        }
        switch (Sub_Mode)
        {
            default:
                break;

            case 0: // '\0'
                if (imgCount < imgNum[Main_Mode])
                {
                    if ( (Main_Mode == 2 || Main_Mode == 3) && imgCount < 4)
                    {
                        drawProlog(g);
                    }
                    if (2 < imgNum[Main_Mode])
                    {
                        drawRoadingBar(g, imgNum[Main_Mode], imgCount + 1);
                    }
                    loadImage(imgCount++);
                    return;
                }
                System.gc();
                if (Main_Mode == 2 || Main_Mode == 3)
                {
                    setThreadTime(250);
                }
                setSubMode( (byte) 1);
                break;

            case 1: // '\001'
                switch (Main_Mode)
                {
                    default:
                        break;

                    case 1: // '\001'
                        drawMainMenu(g);
                        break;

                    case 2: // '\002'
                        drawGame(g);
                        break;

                    case 3: // '\003'
                        drawGame(g);
                        break;

                    case 4: // '\004'
                        switch (method)
                        {
                            case 0: // '\0'
                                drawMethodMenu(g);
                                break;

                            case 1: // '\001'
                                drawStory(g);

                                break;

                            case 2: // '\002'  //is drawInfo;
                                drawInfo(g);
                                break;

                            case 3: // '\003'
                                drawKeyhelp(g);
                                break;
                        }
                        break;

                    case 5: // '\005'
                        drawEnv(g);
                        break;

                    case 6: // '\006'
                        drawRankingView(g);
                        break;

                    case 7: // '\007'
                        drawGameQuestion(g);
                        break;

                    case 0: // '\0'
                        drawGameLogo(g);
                        break;

                    case 8: // '\b'
                        midletExit();
                        break;
                }
                acceptKey = true;
                break;
        }
    }

    public void drawGame(Graphics g)
    {
        label0:
            switch (gm.getGameMode())
        {
            case 0: // '\0'
            default:
                break;

            case 3: // '\003'
                if (gm.subSituCount == 1)
                {
                    gameExit();
                    break;
                }
                // fall through

            case -1:
            case 1: // '\001'

⌨️ 快捷键说明

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