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

📄 splash.java

📁 thq 发布的《worms》 motorola 源代码
💻 JAVA
字号:
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;

public class Splash extends Canvas
    implements Runnable
{

    private Image splash[];
    Random rand;
    private int loadProgress;
    public static boolean loadComplete = false;
    public static boolean paused;
    InputStream is;
    public static Image aboutImg,setImg,startImg,helpImg,againImg,playImg,exitImg;
    public Splash()
    {
        splash = new Image[3];
        rand = new Random();
        loadProgress = 0;
    }

    public void paint(Graphics g)
    {
        if(loadProgress == 0 || paused)
            return;
        if(loadProgress > 14)
        {
            g.setColor(0, 0, 0);
            g.fillRect(0, 0, Game.screenWidth, Game.screenHeight);
            g.drawImage(splash[2], Game.screenWidth >> 1, Game.screenHeight >> 1, 3);
            if(loadProgress > 25)
                loadProgress = 25;
//            g.setColor(50, 0, 200);
//            g.fillRoundRect(33, 20, loadProgress * 4, 10, 10, 10);
//            g.setColor(200, 200, 200);
//            g.drawRoundRect(33, 20, 100, 10, 10, 10);
        } else/*
        if(loadProgress > 11)
        {
            g.setColor(255, 255, 255);
            g.fillRect(0, 0, Game.screenWidth, Game.screenHeight);
            g.drawImage(splash[1], Game.screenWidth >> 1, Game.screenHeight >> 1, 3);
        } else*/
        {
            g.setColor(255, 255, 255);
            g.fillRect(0, 0, Game.screenWidth, Game.screenHeight);
            g.drawImage(splash[0], Game.screenWidth >> 1, Game.screenHeight >> 1, 3);
            g.setColor(50, 0, 200);
            g.fillRoundRect((Game.screenWidth-14*7)/2, Game.screenHeight-30, loadProgress * 7, 10, 10, 10);
            g.setColor(200, 200, 200);
            g.drawRoundRect((Game.screenWidth-14*7)/2, Game.screenHeight-30, 100, 10, 10, 10);
        }
//        g.setColor(255, 255, 255);
//        g.drawString("Loading - Chargement", Game.screenWidth >> 1, Game.screenHeight - 40, 17);
//        g.drawString("Cargamento - Laden", Game.screenWidth >> 1, Game.screenHeight - 20, 17);
    }

    public void destroy()
    {
        for(int i = 0; i < splash.length - 1; i++)
            splash[i] = null;

        splash = null;
        System.gc();
    }

    public void run()
    {
        try
        {
        	//int m = 0;
            Display.getDisplay(Worms.instance).setCurrent(this);
            while(!loadComplete)
            {
            	//System.out.println("======m===="+m);
                if(!paused) {
                    loadNextBatchOfData();
                }
                try
                {
                    Thread.sleep(25L);
                }
                catch(Exception exception) { }
            }
        }
        catch(Exception exception1) { }
    }

    public void loadNextBatchOfData()
    {
        try
        {
            switch(loadProgress)
            {
            default:
                break;

            case 0: // '\0'
                splash[0] = Image.createImage("/logo.png");
                playImg = Image.createImage("/play.png");
                startImg = Image.createImage("/start.png");
                againImg = Image.createImage("/again.png");
                aboutImg = Image.createImage("/about.png");
                setImg = Image.createImage("/set.png");
                exitImg = Image.createImage("/exit.png");
                helpImg = Image.createImage("/help.png");
                //loadAUDIO();
                //createAUDIO();
                break;

            case 1: // '\001'
                Landscape.currentLandscapeIndex = 0;
                Landscape.currentLandscapeIndex = randRange(4);
                if(Landscape.currentLandscapeIndex < 0 || Landscape.currentLandscapeIndex > 3)
                    Landscape.currentLandscapeIndex = 1;
//                DeviceControl.getDefaultDeviceControl().setDeviceActive(5, true);//yue add 1
                break;

            case 2: // '\002'
                splash[1] = Image.createImage("/splash.png");
                break;

            case 3: // '\003'
                splash[2] = Image.createImage("/splash.png");
                break;

            case 4: // '\004'
                Landscape.texture[0] = new Imp("/texture_snow.png", 1);
                break;

            case 5: // '\005'
                Landscape.entities[0] = new Imp("/entity_snow.png", 1);
                break;

            case 6: // '\006'
                Landscape.texture[1] = new Imp("/texture_desert.png", 1);
                break;

            case 7: // '\007'
                Landscape.entities[1] = new Imp("/entity_desert.png", 1);
                break;

            case 8: // '\b'
                Landscape.texture[2] = new Imp("/texture_rock.png", 1);
                break;

            case 9: // '\t'
                Landscape.entities[2] = new Imp("/entity_rock.png", 1);
                break;

            case 10: // '\n'
                Landscape.texture[3] = new Imp("/texture_hill.png", 1);
                break;

            case 11: // '\013'
                Landscape.entities[3] = new Imp("/entity_hill.png", 1);
                break;

            case 12: // '\f'
                Weapon.WeaponIcons = Image.createImage("/WeaponIcons.png");
                /*try
                {
                    is = getClass().getResourceAsStream("/WormsTheme.mid");
                    Game.sound_THEMETUNE = Manager.createPlayer(is, "audio/midi");
                    Game.sound_THEMETUNE.realize();
                    Game.sound_THEMETUNE.setLoopCount(-1);
                }
                catch(IOException ioexception) { }
                catch(MediaException mediaexception) { }*/
                break;

            case 13: // '\r'
                Weapon.rocket = new Imp("/w_rocket_strip.png", 18);
                break;

            case 14: // '\016'
                Weapon.mortar = new Imp("/w_mortar_strip.png", 18);
                break;

            case 15: // '\017'
                Weapon.cluster = new Imp("/w_cluster_strip.png", 18);
                break;

            case 16: // '\020'
                Weapon.grenade = new Imp("/w_grenade_strip.png", 9);
                break;

            case 17: // '\021'
                Weapon.dynamite = new Imp("/w_dynamite_strip.png", 2);
                break;

            case 18: // '\022'
                Weapon.clustlet = new Imp("/w_clustlet_strip.png", 3);
                break;

            case 19: // '\023'
                Weapon.explosion1 = new Imp("/expl1_strip.png", 3);
                Worm.bazooka = new Imp("/wbaz_strip.png", 8);
                break;

            case 20: // '\024'
                Worm.crosshair = new Imp("/crosshair_strip.png", 2);
                Worm.arrow = new Imp("/arrow_strip.png", 2);
                break;

            case 21: // '\025'
                Worm.medic = new Imp("/medic.png", 1);
                Worm.rip = new Imp("/rip.png", 1);
                FontRender.font = new Imp("/font_strip.png", 10);
                break;

            case 22: // '\026'
                Worm.walk = new Imp("/wleft_strip.png", 3);
                Game.water = new Imp("/water.png", 1);
                break;

            case 23: // '\027'
                Game.cloud = new Imp("/cloud.png", 1);
                Game.icons = new Imp("/icon_strip.png", 2);
                break;

            case 24: // '\030'
                Game.surrender = new Imp("/wwave_strip.png", 3);
                break;

            case 25: // '\031'
                Game.windIconRed = new Imp("/wind_icon_red_strip.png", 1);
                Game.windIconBlue = new Imp("/wind_icon_blue_strip.png", 1);
                /*if(Menu.soundEnabled()) {
                    //Game.sound_THEMETUNE.start();
                	Game.sound.close();
    				Game.sound.getPlayer(1);
    				Game.sound.start();
                }*/    
                
                loadComplete = true;
                break;
            }
            repaint();
            loadProgress++;
        }
        catch(Exception exception) { }
    }

    int randRange(int i)
    {
        int j = rand.nextInt() % i;
        if(j < 0)
            j += i;
        return j;
    }

    /*public void createAUDIO()
    {
        try
        {
            is = getClass().getResourceAsStream("/explosion.wav");
            Game.sound_EXPLOSION = Manager.createPlayer(is, "audio/x-wav");
            //Game.sound_EXPLOSION.prefetch();
            Game.sound_EXPLOSION.realize();
        }
        catch(IOException ioexception) { }
        catch(MediaException mediaexception) { }
        try
        {
            is = getClass().getResourceAsStream("/victory.wav");
            Game.sound_VICTORY = Manager.createPlayer(is, "audio/x-wav");
            Game.sound_VICTORY.realize();
        }
        catch(IOException ioexception1) { }
        catch(MediaException mediaexception1) { }
        try
        {
            is = getClass().getResourceAsStream("/byebye.wav");
            Game.sound_BYEBYE = Manager.createPlayer(is, "audio/x-wav");
            Game.sound_BYEBYE.realize();
        }
        catch(IOException ioexception2) { }
        catch(MediaException mediaexception2) { }
    }
*/
}

⌨️ 快捷键说明

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