?? bullet.java
字號:
/*
* Bullet.java
*
* Created on 2006年4月17日, 下午5:10
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class Bullet {
/** Creates a new instance of Bullet */
/**
*[i][0]子彈X坐標
*[i][1]子彈Y坐標
*[i][2]子彈Y方向速度
*[i][3]子彈X方向的速度
*[i][4]子彈的存活狀態property
*[i][5]子彈的初始X坐標
*[i][6]子彈的初始Y坐標
*[i][7]標志子彈是否已經改變狀態
*[i][8]子彈的方向
*[i][9]圖片的寬
*[i][10]圖片的高
*[i][11]標識為哪種類型的精靈發出的箭支
*[i][12]精靈的射程.
*[i][13]子彈在圖片中的X坐標
*[i][14]子彈在圖片中的Y坐標
*[i][15]子彈的攻擊力
*/
public static final int PLAY_BULLET_NUM = 12;
public static final int PLAY_PROPERTY = 16;
private int[][] Play_Rocket = new int[3][PLAY_PROPERTY];//玩家的火箭支數
//public int gunshot = 100;
public int[][] play_bullet = new int[PLAY_BULLET_NUM][PLAY_PROPERTY];//玩家的子彈//是否可以通用?
private Hero hero_play;
private Image bullet_image = null;
private int[] play_explosion = {//x:y:w:h
13,14,5,5,
42,11,12,12,
70,8,21,18,
96,0,32,32
};
private int[] explosion = {//幀序列:播放時間
0,50,
1,50,
2,50,
3,50
};
public static boolean is_explosion;//標志玩家發射的火箭是否要到爆炸的時間
private long explosion_start;
int explosion_i = 0;
protected int x,y;//當前爆炸的地點
protected int w, h; //當前爆炸圖像的寬,高
protected int x1,y1;//當前爆炸圖象在大圖片的位置
//敵人的子彈的各個屬性------------------------------------------------
protected static final int FOE_BULLET_NUM = 30;//精靈子彈的個數
private int[][] foe_bullet = new int[FOE_BULLET_NUM][PLAY_PROPERTY];
private Foe foe_sprite;//敵人類
//----------------------------------------------------------------------------------------------
public Bullet(Hero hreo) {
hero_play = hreo;
ini_play_bullet();
ini_foe_bullet();
ini_rocket_bullet();
is_explosion = false;
}
public void ini_play_bullet(){
for(int i = 0;i<PLAY_BULLET_NUM;i++){
for(int j=0;j<PLAY_PROPERTY;j++){
play_bullet[i][j] = 0;
}
}
}
public void ini_rocket_bullet(){
for(int i = 0;i<3;i++){
for(int j=0;j<PLAY_PROPERTY;j++)
Play_Rocket[i][j] = 0;
}
}
/**
*初始化精靈子彈
*/
public void ini_foe_bullet(){
for(int i = 0;i<FOE_BULLET_NUM;i++){
for(int j = 0;j<PLAY_PROPERTY;j++){
foe_bullet[i][j] = 0;
}
}
}
/**
*設置玩家子彈的原始坐標
*@parameter play_sort:發箭的類型1表示玩家的弓箭.2表示跟隨者的類型
*/
public void set_bullet_point(int x ,int y,int play_sort){
boolean tem1=false;
int tem_num = 2;
for(int i=0;i<PLAY_BULLET_NUM;i++){
if(play_sort == 2){//hero_play.hero_property[9]!=0 && hero_play.hero_property[11]==1
if(play_bullet[i][4] != 1 && tem_num > 0){
play_bullet[i][0] = x;
play_bullet[i][1] = y;
play_bullet[i][5] = x;
play_bullet[i][6] = y;
play_bullet[i][11] = play_sort;
play_bullet[i][4] = 1;
tem_num = tem_num - 2;
}
}else{//設置玩家子彈開始
if(hero_play.hero_property[1] ==2){//雙發子彈
if(play_bullet[i][4] != 1 && tem_num > 0){
if(tem_num == 1){
play_bullet[i][0] = x;
play_bullet[i][1] = y;
play_bullet[i][5] = x;
play_bullet[i][6] = y;
} else{
play_bullet[i][0] = x + 5;
play_bullet[i][1] = y;
play_bullet[i][5] = x + 5;
play_bullet[i][6] = y;
}
play_bullet[i][11] = 1;//1表示玩家發射的弓箭,2表示跟隨者發射的弓箭
play_bullet[i][4] = 1;
tem_num--;
}
} else{//單發
if(play_bullet[i][4] != 1 && tem_num > 0){
play_bullet[i][0] = x;
play_bullet[i][1] = y;
play_bullet[i][5] = x;
play_bullet[i][6] = y;
play_bullet[i][11] = 1;
play_bullet[i][4] = 1;
tem_num = tem_num - 2;
}
}
}//設置玩家子彈結束
//play_bullet[i][11] = play_sort;
}
}
/**
*設置玩家發射火箭時的原始坐標
*/
public void set_rocket_bullet_point(int x,int y){
boolean tem_rocket = false;
for(int i = 0;i<3;i++){
if(Play_Rocket[i][4] !=1 && !tem_rocket){
Play_Rocket[i][0] = x;
Play_Rocket[i][1] = y;
Play_Rocket[i][5] = x;
Play_Rocket[i][6] = y;
Play_Rocket[i][4] = 1;
tem_rocket = true;
}
}
}
/**
*設置玩家的速度
*/
public void set_bullet_speed(){
for(int i = 0;i<this.PLAY_BULLET_NUM;i++){
if(play_bullet[i][4] == 1 && play_bullet[i][7] !=1){
switch(hero_play.hero_property[8]){
case 1://向左發
play_bullet[i][3] = (-1)*hero_play.hero_property[18] * 7071/10000;//X方向速度
play_bullet[i][2] = (-1)*hero_play.hero_property[18] * 7071/10000;//Y方向速度
play_bullet[i][8] = 1;
break;
case 2://向上發
play_bullet[i][3] = 0;
play_bullet[i][2] = (-1)*hero_play.hero_property[18];
play_bullet[i][8] = 2;
break;
case 3://向右發
play_bullet[i][3] = hero_play.hero_property[18] * 7071/10000;
play_bullet[i][2] = (-1) * hero_play.hero_property[18] * 7071/10000;
play_bullet[i][8] = 3;
break;
}
if(play_bullet[i][11]==1){//玩家的子彈
if(hero_play.hero_property[1]==1){//穿心箭
play_bullet[i][13] = arrow_attack_area[(play_bullet[i][8]+2)*4];
play_bullet[i][14] = arrow_attack_area[(play_bullet[i][8]+2)*4+1];
play_bullet[i][9] = arrow_attack_area[(play_bullet[i][8]+2)*4+2];
play_bullet[i][10] = arrow_attack_area[(play_bullet[i][8]+2)*4+3];
}else{//普通箭
play_bullet[i][13] = arrow_attack_area[(play_bullet[i][8]-1)*4];
play_bullet[i][14] = arrow_attack_area[(play_bullet[i][8]-1)*4+1];
play_bullet[i][9] = arrow_attack_area[(play_bullet[i][8]-1)*4+2];
play_bullet[i][10] = arrow_attack_area[(play_bullet[i][8]-1)*4+3];
}
}else{//跟隨者箭
play_bullet[i][13] = arrow_attack_area[(play_bullet[i][8]-1)*4];
play_bullet[i][14] = arrow_attack_area[(play_bullet[i][8]-1)*4+1];
play_bullet[i][9] = arrow_attack_area[(play_bullet[i][8]-1)*4+2];
play_bullet[i][10] = arrow_attack_area[(play_bullet[i][8]-1)*4+3];
}
play_bullet[i][7] = 1;
}
}
}
/**
*設置玩家發射火箭的速度
*/
public void set_rocket_bullet_speed(){
for(int i = 0;i<3;i++){
if(Play_Rocket[i][4] ==1 && Play_Rocket[i][7]!=1){
switch(hero_play.hero_property[8]){
case 1://向左發
Play_Rocket[i][3] = (-1)*hero_play.hero_property[21] * 7071/10000;//X方向速度
Play_Rocket[i][2] = (-1)*hero_play.hero_property[21] * 7071/10000;//Y方向速度
Play_Rocket[i][8] = 1;
break;
case 2://向上發
Play_Rocket[i][3] = 0;
Play_Rocket[i][2] = (-1)*hero_play.hero_property[21];
Play_Rocket[i][8] = 2;
break;
case 3://向右發
Play_Rocket[i][3] = hero_play.hero_property[21] * 7071/10000;
Play_Rocket[i][2] = (-1) * hero_play.hero_property[21] * 7071/10000;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -