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

📄 boss.java

📁 手机射击游戏源代码,nokia s60模拟器开发包,eclipse工具开发.不可用于商业用途.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package src;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Boss {
	Image imgb[];

	//boss1
	Bullets b1_bullets1[], b1_bullets2[], b1_bullets3[], b2_bullets_1[],
			b2_bullets_2[], b2_bullets_3[], boss3_b3[], boss4_b1[], boss5b_1[],
			boss5b_2[];

	Sprite boss1[], boss2[], boss3[], boss4[], boss5[];

	boolean isAlive, isHit;

	int Boss2_boom[] = { 0, 0, 1, 1, 2, 2, 3, 3, 3, };

	int boss2_bullet[] = { 0, 0, 1, 1 };

	int x1 = 0;

	int x2 = 0;

	int boss2_boom2 = 0;

	int boss2_m = 180, boss2_n = 0;

	int boom_x, boom_y;

	int boss3_x = 0, boss3_y = -50;

	int boss3_x1 = 25 + boss3_x, boss3_y1 = 2 + boss3_y;

	int boss3_x2 = 125 + boss3_x, boss3_y2 = 2 + boss3_y;

	int boss3_x3 = 69 + boss3_x, boss3_y3 = 55 + boss3_y;

	int boss3_x4 = 56 + boss3_x, boss3_y4 = 35 + boss3_y;

	int boss3_x5 = 100 + boss3_x, boss3_y5 = 35 + boss3_y;

	boolean boss3_Xl = false;

	boolean boss3_Xr = false;

	boolean boss3_mingld = false;

	boolean boss3_mingrd = false;

	boolean boss3_minglq = true;

	boolean boss3_mingrq = true;

	boolean boss3_run_t = false;

	boolean boss3_run_a = false;

	boolean boss3_run_b = false;

	int boss3_f = 0;
	
	boolean h = false; //判断boss[8]与player的碰撞

	boolean n = false; //判断boss[9]与player的碰撞
    
	boolean m=false;
	
	boolean k=false;

	boolean X_fire_t = true;

	int X_fire = 0;

	//boss1 变量
	int boss_x = 90, boss_y =-15;

	boolean boss1_b[] = { false, false, false, false, false, false, true, true,
			false, false };

	int boss1_x[] = { 110 + boss_x, 95 + boss_x, 70 + boss_x, 63 + boss_x,
			82 + boss_x, 150 + boss_x, 140 + boss_x, 0, 0, 0, 0, 300, 0 };

	int boss1_y[] = { 108 + boss_y, 105 + boss_y, 120 + boss_y, 125 + boss_y,
			135 + boss_y, 120 + boss_y, 100 + boss_y };

	//	boss2 变量
	int boss2_x[] = { -50 + boss2_m, 20 + boss2_m, 80 + boss2_m, 100 + boss2_m,
			150, 80, 80, 10, 0 };

	int boss2_y[] = { 5 + boss2_n, 25 + boss2_n, 45 + boss2_n, 45 + boss2_n };
	
	//boss3 变量
	int boss3_w = 0, boss3_v = -50;

	int x11 = 0;

	int x22 = 0;
	
	int boss3_fire = 0;
	
	boolean boss3_dl = false;
	
	int boss3_dlming = 120;
	
	int boss3_drming = 120;
	
	int boss3_xrming = 80;

	int boss3_xlming = 80;

	boolean boss3_dr = false;
	
	boolean boss2_b[] = { false, false, false, false, true, false, true };

	boolean boss3_dlboom = false;

	boolean boss3_drboom = false;
	
	//boss4 变量
	int boss4_i = 1800, boss4_j = 70;

	boolean boss4_bt[] = { true, true, false, false, false, false };

	int boss4_x[] = { boss4_i - 3, 0, 100, 0 };

	int boss4_y[] = { boss4_j + 20 };
	
	//boss5变量
	int boss5_x = 35, boss5_y = 65;

	int boss5_x1 = 69, boss5_y1 = -30;

	int boss5_x2 = 10, boss5_y2 = 30;

	int boss5_x3 = 140, boss5_y3 = 30;

	boolean mm = false;

	boolean nn = false;

	boolean boss5_boom = false;

	int boss5_run = 0;

	int boss5_ming = 500;
	boolean boss5_run_t1 = true;

	boolean boss5_run_t2 = false;

	boolean boss5_r = false;

	int yong = 0;
	
	GameDataSimple gt;

	public Boss() {
		if (imgb==null){
			imgb = new Image[30];
			gt = new GameDataSimple();
			gt.createImage(imgb, "bossImage.c", 0, 30, this);
		}		
	}

	void initBoss1() {
		b1_bullets1 = new Bullets[10];

		b1_bullets2 = new Bullets[10];

		b1_bullets3 = new Bullets[10];

		boss1 = new Sprite[20];

		boss1[0] = new Sprite(imgb[0], 107, 45);
		boss1[0].setFrameSequence(boss2_bullet);

		boss1[1] = new Sprite(imgb[1], 50, 31);
		boss1[1].setFrame(0);

		boss1[2] = new Sprite(imgb[2], 28, 26);
		boss1[2].setFrame(0);

		boss1[3] = new Sprite(imgb[2], 28, 26);
		boss1[3].setFrame(0);

		boss1[4] = new Sprite(imgb[3], 16, 23);
		boss1[4].setFrame(0);

		boss1[5] = new Sprite(imgb[3], 16, 23);
		boss1[5].setFrame(0);

		boss1[6] = new Sprite(imgb[4], 40, 29);
		boss1[6].setFrame(0);

		boss1[7] = new Sprite(imgb[5], 25, 28);

		boss1[8] = new Sprite(imgb[6], 20, 35);
		boss1[8].setFrame(0);

		boss1[9] = new Sprite(imgb[7], 10, 10);
		boss1[9].setFrameSequence(boss2_bullet);

		boss1[10] = new Sprite(imgb[8], 13, 13);
		boss1[10].setFrameSequence(boss2_bullet);

		for (int i = 0; i < b1_bullets1.length; i++) {
			b1_bullets1[i] = new Bullets(boss1[9]);
			b1_bullets2[i] = new Bullets(boss1[7]);
			b1_bullets3[i] = new Bullets(boss1[10]);
		}
		isAlive = false;
	}

	void initBoss2() {
		b1_bullets1=null;
		b1_bullets2=null;
		b1_bullets3=null;
		boss1=null;
		boss1_x=null;
		boss1_y=null;
		boss1_b=null;
		
		b2_bullets_1 = new Bullets[10];

		b2_bullets_2 = new Bullets[10];

		b2_bullets_3 = new Bullets[10];

		boss2 = new Sprite[11];

		boss2[0] = new Sprite(imgb[9], 205, 166);
		boss2[0].setFrame(0);
		boss2[1] = new Sprite(imgb[10], 58, 45);
		boss2[1].setFrame(0);
		boss2[2] = new Sprite(imgb[11], 18, 22);
		boss2[3] = new Sprite(imgb[11], 18, 22);
		boss2[4] = new Sprite(imgb[15], 45, 45);
		boss2[4].setFrameSequence(Boss2_boom);
		boss2[5] = new Sprite(imgb[6], 20, 35);
		boss2[5].setFrameSequence(Boss2_boom);
		boss2[6] = new Sprite(imgb[6], 20, 35);
		boss2[6].setFrameSequence(Boss2_boom);
		boss2[7] = new Sprite(imgb[12], 50, 40);
		boss2[7].setFrameSequence(boss2_bullet);
		boss2[8] = new Sprite(imgb[13], 50, 30);
		boss2[8].setFrameSequence(boss2_bullet);
		boss2[9] = new Sprite(imgb[14], 8, 8);
		boss2[9].setFrameSequence(boss2_bullet);
		boss2[10] = new Sprite(imgb[15], 45, 45);
		boss2[10].setFrameSequence(Boss2_boom);

		for (int i = 0; i < b2_bullets_1.length; i++) {
			b2_bullets_1[i] = new Bullets(boss2[7]);
			b2_bullets_2[i] = new Bullets(boss2[8]);
			b2_bullets_3[i] = new Bullets(boss2[9]);
		}
		isAlive = false;
	}

	void initBoss3() {
		b2_bullets_1 = null;

		b2_bullets_2 = null;

		b2_bullets_3 = null;

//		boss2 = null;
		
//		boss2_x=null;
//		boss2_y=null;
//		boss2_b=null;
		
		boss3_b3 = new Bullets[20];

		boss3 = new Sprite[13];

		boss3[0] = new Sprite(imgb[16], 170, 55);
		boss3[0].setFrame(0);

		boss3[1] = new Sprite(imgb[17], 22, 53);
		boss3[1].setFrame(0);

		boss3[2] = new Sprite(imgb[17], 22, 53);
		boss3[2].setFrame(1);

		boss3[3] = new Sprite(imgb[18], 32, 27);
		boss3[3].setFrame(0);

		boss3[4] = new Sprite(imgb[19], 13, 17);

		boss3[5] = new Sprite(imgb[19], 13, 17);

		boss3[6] = new Sprite(imgb[20], 16, 19);
		boss3[7] = new Sprite(imgb[20], 16, 19);
		boss3[8] = new Sprite(imgb[21], 16, 110);

		boss3[9] = new Sprite(imgb[21], 16, 110);
		boss3[10] = new Sprite(imgb[14], 8, 8);
		boss3[10].setFrameSequence(boss2_bullet);
		boss3[11] = new Sprite(imgb[15], 45, 45);
		boss3[11].setFrameSequence(Boss2_boom);
		boss3[12] = new Sprite(imgb[15], 45, 45);
		boss3[12].setFrameSequence(Boss2_boom);

		for (int i = 0; i < boss3_b3.length; i++) {
			boss3_b3[i] = new Bullets(boss3[10]);
		}
		isAlive = false;
	}

	void initBoss4() {
		boss3_b3 = null;

		boss3 = null;
		
		boss4_b1 = new Bullets[50];

		boss4 = new Sprite[11];

		boss4[0] = new Sprite(imgb[22], 120, 90);
		boss4[0].setFrame(0);
		boss4[1] = new Sprite(imgb[23], 35, 35);

		boss4[2] = new Sprite(imgb[24], 11, 11);
		boss4[2].setFrameSequence(boss2_bullet);
		boss4[3] = new Sprite(imgb[25], 100, 5);

		boss4[4] = new Sprite(imgb[26], 8, 8);
		boss4[4].setFrameSequence(boss2_bullet);

		boss4[5] = new Sprite(imgb[15], 45, 45);
		boss4[5].setFrameSequence(Boss2_boom);

		boss4[6] = new Sprite(imgb[15], 45, 45);
		boss4[6].setFrameSequence(Boss2_boom);
		for (int i = 0; i < boss4_b1.length; i++) {
			boss4_b1[i] = new Bullets(boss4[4]);
		}
		isAlive = false;
	}

	void initBoss5() {
//		boss4_b1 = null;
//
//		boss4 = null;
		
		boss5b_1 = new Bullets[30];

		boss5b_2 = new Bullets[30];

		boss5 = new Sprite[15];

		boss5[0] = new Sprite(imgb[27], 113, 98);
		boss5[0].setFrame(0);
		boss5[1] = new Sprite(imgb[28], 45, 41);
		boss5[1].setFrame(0);
		boss5[2] = new Sprite(imgb[29], 27, 25);

		boss5[3] = new Sprite(imgb[29], 27, 25);
		boss5[4] = new Sprite(imgb[21], 16, 110);
		boss5[4].setFrame(1);
		boss5[5] = new Sprite(imgb[21], 16, 110);
		boss5[5].setFrame(1);
		boss5[6] = new Sprite(imgb[7], 10, 10);
		boss5[6].setFrameSequence(boss2_bullet);
		boss5[7] = new Sprite(imgb[7], 10, 10);
		boss5[7].setFrameSequence(boss2_bullet);
		boss5[8] = new Sprite(imgb[7], 10, 10);
		boss5[8].setFrameSequence(boss2_bullet);

		boss5[9] = new Sprite(imgb[7], 10, 10);
		boss5[9].setFrameSequence(boss2_bullet);

		boss5[10] = new Sprite(imgb[7], 10, 10);
		boss5[10].setFrameSequence(boss2_bullet);

		boss5[11] = new Sprite(imgb[15], 45, 45);
		boss5[11].setFrameSequence(Boss2_boom);

		boss5[12] = new Sprite(imgb[15], 45, 45);
		boss5[12].setFrameSequence(Boss2_boom);

		for (int i = 0; i < boss5b_1.length; i++) {
			boss5b_1[i] = new Bullets(boss5[7]);
			boss5b_1[i] = new Bullets(boss5[6]);
			boss5b_2[i] = new Bullets(boss5[10]);
		}
		isAlive = false;
	}

	void paint_zidan(Graphics g, int can) {
		for (int i = 0; i < 10; i++) {
			switch (can) {
			case 1:
				if (b1_bullets1[i].live == false) {

					b1_bullets1[i].x = boss1_x[3] - 20;
					b1_bullets1[i].y = boss1_y[3] + 10;

					b1_bullets1[i].live = true;
					return;
				}
				break;
			case 2:
				if (b1_bullets1[i].live == false) {
					b1_bullets1[i].x = boss1_x[4] - 20;
					b1_bullets1[i].y = boss1_y[4] + 10;
					b1_bullets1[i].live = true;
					return;
				}
				break;
			case 3:
				if (b1_bullets2[i].live == false) {
					b1_bullets2[i].x = boss1_x[1] - 25;
					b1_bullets2[i].y = boss1_y[1] - 5;
					b1_bullets2[i].live = true;
					return;
				}
				break;
			case 4:
				if (b1_bullets3[i].live == false) {
					b1_bullets3[i].x = boss1_x[6] - 10;
					b1_bullets3[i].y = boss1_y[6] - 5;
					b1_bullets3[i].live = true;

					return;
				}
				break;
			case 5:
				if (b1_bullets3[i].live == false) {
					b1_bullets3[i].x = boss1_x[6] - 20;
					b1_bullets3[i].y = boss1_y[6] - 10;
					b1_bullets3[i].live = true;
					return;
				}
				break;
			case 6:
				if (b2_bullets_1[i].live == false) {
					b2_bullets_1[i].x = boss2_x[1] - 40;
					b2_bullets_1[i].y = boss2_y[1] - 20;
					b2_bullets_1[i].live = true;
					return;
				}
				break;
			case 7:
				if (b2_bullets_2[i].live == false) {
					b2_bullets_2[i].x = -20;
					b2_bullets_2[i].y = 140;
					b2_bullets_2[i].live = true;
					b2_bullets_2[i].visible = true;
					return;
				}
				break;
			case 8:
				if (boss4_b1[i].live == false) {
					boss4_b1[i].x = boss4_x[0] - 10;
					boss4_b1[i].y = boss4_y[0] + 25;
					boss4_b1[i].live = true;
					return;
				}
				break;
			}
		}
	}

	void paint_boss1(Graphics g) {

		boss1[1].setPosition(boss1_x[0], boss1_y[0]);//1

		boss1[2].setPosition(boss1_x[3], boss1_y[3]);//3
		boss1[4].setPosition(boss1_x[5], boss1_y[5]);//5

		boss1[0].setPosition(boss1_x[2], boss1_y[2]);//7

		boss1[6].setPosition(boss1_x[1], boss1_y[1]);//9

		boss1[5].setPosition(boss1_x[6], boss1_y[6]); //11
		boss1[3].setPosition(boss1_x[4], boss1_y[4]);//13
		boss1[8].setPosition(boss1_x[1] - 25, boss1_y[1] - 33);//14

		for (int i = 0; i < b1_bullets1.length; i++) {
			if (b1_bullets1[i].live == true)
				b1_bullets1[i].paint(g);
			if (b1_bullets2[i].live == true) {

				if (b1_bullets2[i].a == 0)
					b1_bullets2[i].setFrame(0);
				if (b1_bullets2[i].a == 1)
					b1_bullets2[i].setFrame(1);

				b1_bullets2[i].paint(g);
			}

			if (b1_bullets3[i].live == true)
				b1_bullets3[i].paint(g);

		}

		if (!boss1_b[3]) {
			boss1[5].paint(g);

			if (boss1_x[9] == 61) {

				paint_zidan(g, 4);
			}

		}

		if (!boss1_b[4]) {
			boss1[1].paint(g);

		}

		boss1[0].paint(g);
		boss1[0].nextFrame();

		if (!boss1_b[0]) {
			boss1[2].paint(g);
			boss1[3].paint(g);

			if (boss1_x[8] == 61) {
				paint_zidan(g, 1);
				paint_zidan(g, 2);
			}
		}

		if (!boss1_b[2]) {

			boss1[4].paint(g);

			if (boss1_x[9] == 61) {
				paint_zidan(g, 5);
			}
		}

⌨️ 快捷键说明

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