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

📄 load.java

📁 手机RPG游戏
💻 JAVA
字号:
package main;

import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import java.io.*;

//装入了所有程序所用的图片,和音乐。

public class Load {
public int pass=0;//总关数,关卡数//Boss的图片号
private int speed=1;//屏幕背景的移动量度
//************************************************
public int myPlanHp=50;//生命值50;
public int myPlanHpMax=50;//生命最大值
public int myPlanOverScore=100;//玩家飞机死后减多少分.
public int myPlanOverTime=20;//玩家飞机死后多长时间再出现.
public int myPlanTimes=3;//玩家可以有几次机会。

public int myPlanId=0;//玩家飞机的色,0是红色,1是蓝色
public int myBulletId=0;//玩家子弹的种类号
public int myBulletSpeed=-10;//玩家子弹的速度
public int myBulletMax=5;//玩家子弹的最大数量
public int d=3;//玩家飞机的移动变化量
public int space=10;//玩家飞机边界

public int passNum=5;//玩家每过几关加一条命。
public int scoreAdd=1000;//玩家每过多少分加一条命。

//*****************************
public int bossHp=50;
public int bossScore=200;//打死Boss的得分.
public int bossShow=10;//敌机出现多少时,出现Boss
public int area=9;//Boss闪电的范围
public int bossBulletId=0;//Boss子弹号
public int bossBulletSpeed=pass+1;//Boss子弹的y速度
public int bossBulletMax=8;//产生子弹的最大数
public int bossBulletNatality=25;//Boss产生子弹的间隔
public int bossBulletHit=10;//Boss子弹的打击力
public int bossLevinHit=20;//Boss闪电的打击力.
//******************************************************
public int bootyNatality=300;//奖励出现的时间间隔
public int bootyScore=100;//得到金币的得分.
public int bootyAddHp=10;//每个奖励加生命多少.( * BootyId)
//****************************************************
public int n=4;//第几个图片是流星
public int aeroliteMax=10;//陨石的最大数量。
public int aeroliteNatality=30;//陨石的产生间隔
public int aeroliteScore=5;//打爆一个陨石的得分.
//*****************************************************
public int enemyMax=10;//敌机的最大数
public int enemyNatality=20;//敌机产生的间隔数
public int enemyScore=5;//打爆一个敌机的得分.
public int enemyBulletHit=5;//敌机子弹的打击力

//************************************************************
   //下面全是图片
  public Image bootyImg[]=new Image[5];//战利品图片
  public Image aeroliteImg[]=new Image[6];//陨石图片
  public Image enemyImg[]=new Image[6];//敌人飞机图片
  public Image bossImg[]=new Image[1];//Boss图片
  public Image bossbulletImg[]=new Image[1];//Boss子弹图片
  public Image enemybulletImg[]=new Image[1];//敌机子弹
  public Image mybulletImg[]=new Image[1];//玩家子弹
  public Image myplanImg[]=new Image[2];//玩家的几种样子
  public Image skyImg[]=new Image[1];//天空背景(每关一个)
  public Image explodeImg[]=new Image [8];//爆炸效果。
  public Image bulletExplodImg[]=new Image[3];//子弹爆炸效果
  public Image gameOverImg;//游戏结束的图

//音乐,音效。
  public Player BackMid;//背景音乐
  public Player myBulletMid;
  public Player enemyBullet0Mid;
  public Player enemyBullet1Mid;
  public Player explodeMid;

  public void Loadinit() {
    try {
      InputStream back=getClass().getResourceAsStream("/res/back.mid");//背景音乐。
      InputStream myBullet=getClass().getResourceAsStream("/res/mybullet.wav");//玩家子弹
      InputStream enemyBullet0=getClass().getResourceAsStream("/res/enemybullet0.wav");//boss子弹。
      InputStream enemyBullet1=getClass().getResourceAsStream("/res/enemybullet1.wav");//boss闪电。
      InputStream explode=getClass().getResourceAsStream("/res/explode.wav");//爆炸

        BackMid=Manager.createPlayer(back,"audio/midi");//背景音乐。
        myBulletMid=Manager.createPlayer(myBullet,"audio/x-wav");
        enemyBullet0Mid=Manager.createPlayer(enemyBullet0,"audio/x-wav");
        enemyBullet1Mid=Manager.createPlayer(enemyBullet1,"audio/x-wav");
        explodeMid=Manager.createPlayer(explode,"audio/x-wav");


        gameOverImg=Image.createImage("/res/gameOver.png");
         for (int i=0;i<bulletExplodImg.length;i++){//子弹爆炸效果
              bulletExplodImg[i]=Image.createImage("/res/bulletExplode_"+i+".png");
         }

        for (int i=0;i<explodeImg.length;i++){////爆炸效果
            explodeImg[i]=Image.createImage("/res/explode_"+i+".png");
        }
        for (int i=0;i<skyImg.length;i++){//天空背景(每关一个)
         skyImg[i]=Image.createImage("/res/sky_"+i+".png");
        }
        for (int i=0;i<mybulletImg.length;i++){//玩家子弹
         mybulletImg[i]=Image.createImage("/res/mybullet_"+i+".png");
        }
       for (int i=0;i<myplanImg.length;i++){//玩家的几种样子
        myplanImg[i]=Image.createImage("/res/myplan_"+i+".png");
       }
        for (int i=0;i<bootyImg.length;i++){//战利品图片
        bootyImg[i]=Image.createImage("/res/booty_"+i+".png");
        }
        for (int i=0;i<aeroliteImg.length;i++){//陨石图片
        aeroliteImg[i]=Image.createImage("/res/aerolite_"+i+".png");
        }
        for(int i=0;i<enemyImg.length;i++)//敌人飞机图片
        {enemyImg[i]=Image.createImage("/res/enemy_"+i+".png");
        }
        for(int i=0;i<bossImg.length;i++)/////Boss图片、Boss子弹图片
        {bossImg[i]=Image.createImage("/res/boss_"+i+".png");
         bossbulletImg[i]=Image.createImage("/res/bossbullet_"+i+".png");
        }
        for(int i=0;i<enemybulletImg.length;i++)//敌机子弹
        {enemybulletImg[i]=Image.createImage("/res/enemybullet_"+i+".png");
        }
  }
  catch (Exception ex) {
     System.out.println("load res E");
  }

    }




}

⌨️ 快捷键说明

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