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

📄 frboss.java

📁 J2ME飞机设计游戏,希望对学习J2ME的程序员有所帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		if (bossCannon.getEnemyLife() > 0) {   //如果BOSS没有血就不产生子弹
			for (int i = 4; i < 6; i++) {
				if (smallCannon[i].getEnemyLife() > 0) { // 如果小炮没有血就不产生子弹
					if (bulletTimes % 30 == 0) {
						
						world.newBullet(3,
								smallCannon[i].getIPosX() + (7 << 8),
								smallCannon[i].getIPosY() + (24 << 8), 0,
								-5 << 8);
					}
				}
			}

			if (bulletTimes % 50 == 0) {
				for (int idx = 0; idx < 9; idx++) {

					world.newBullet(2, bossCannon.getIPosX() + (19 << 8),
							bossCannon.getIPosY() + (32 << 8), xSpeed[idx],
							ySpeed[idx]);
				}
			}

			if (doubleCannon.getEnemyLife() > 0) {
				if (bulletTimes % 60 >= 0 && bulletTimes % 60 <= 5) {
					if (bulletInterval % 2 == 0) {
						world.newBullet(3,
										doubleCannon.getIPosX() + (4 << 8),
										doubleCannon.getIPosY() + (26 << 8), 0,
										-7 << 8);
						
						world.newBullet(3, doubleCannon.getIPosX()
										+ (22 << 8), doubleCannon.getIPosY()
										+ (26 << 8), 0, -7 << 8);
					}
				}
			}

			for (int cCannonIdx = 0; cCannonIdx < 2; cCannonIdx++) {
				if (cirlceCannon[cCannonIdx].getEnemyLife() > 0) {
					if (bulletTimes % 70 >= 0 && bulletTimes % 70 <= 4) {
						for (int i = 0; i < 4; i++) {
							
							world.newBullet(4, cirlceCannon[cCannonIdx]
											.getIPosX() + (5 << 8),
											cirlceCannon[cCannonIdx]
													.getIPosY() + (5 << 8),
											xCirlceSpeed[i * 5
													+ (bulletTimes % 70)],
											yCirlceSpeed[i * 5
													+ (bulletTimes % 70)]);
						}
					}
				}
			}

			if(bulletTimes == 75){
				bulletTimes = 30;
			}
			
			if (bulletInterval == 6) {
				bulletInterval = 0;
			}

			bulletTimes++;
			bulletInterval++;
		}else{
			BOSS_STATE = GameConstant.STATE_BOSS_DIE;
			planeActor.setInvincible(true);
			BattlePlaneActor.PLANESTATE = GameConstant.STATE_GAME_WIN;
			bulletInterval = 0;
		}
	}

	public void initNormalFightXYSpeed() {
		// 已310度到230度的角
		xSpeed = Tool.getXSpeedByAngle(330,9,15,4);
		ySpeed = Tool.getYSpeedByAngle(330,9,15,4);
	}
	
	public void initCrazyFightXYSpeed(){
		// 从90度到450度的角
		xCirlceSpeed = Tool.getXSpeedByAngle(450,20,18,6);
		yCirlceSpeed = Tool.getYSpeedByAngle(450,20,18,6);
	}
	
	public void isCollideWithBoss(Bullet bullet) {
		switch (BOSS_STATE) {
		case GameConstant.STATE_BOSS_NORMAL_FIGHT:

			if (isCollideInLeftTop(bullet, artillery)) {
				artillery.setEnemyLife(artillery.getEnemyLife()
						- bullet.getDamage());

				world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
						+ (15 << 8), 0, 0);
				isCollide = true;
				
				if (artillery.getEnemyLife() <= 0) {
					BattlePlaneActor.iScore += 100;
				}
			}

			for (int i = 0; i < 4; i++) {
				if (smallCannon[i].getEnemyLife() > 0) {
					if (isCollideInLeftTop(bullet, smallCannon[i])) {
						smallCannon[i].setEnemyLife(smallCannon[i]
								.getEnemyLife()
								- bullet.getDamage());
						world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
								+ (15 << 8), 0, 0);
						isCollide = true;

						if (smallCannon[i].getEnemyLife() <= 0) {
							BattlePlaneActor.iScore += 50;
						}
					}
				}
			}

			break;
		case GameConstant.STATE_BOSS_CRAZY_FIGHT:
			// 判断和小炮的碰撞
			for (int cannonIdx = 4; cannonIdx < 6; cannonIdx++) {
				if (smallCannon[cannonIdx].getEnemyLife() > 0) {
					if (isCollideInLeftTop(bullet, smallCannon[cannonIdx])) {

						smallCannon[cannonIdx]
								.setEnemyLife(smallCannon[cannonIdx]
										.getEnemyLife()
										- bullet.getDamage());

						world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
								+ (15 << 8), 0, 0);
						isCollide = true;

						if (smallCannon[cannonIdx].getEnemyLife() <= 0) {
							BattlePlaneActor.iScore += 50;
						}
					}
				}
			}

			// 判断与双管炮的碰撞
			if (doubleCannon.getEnemyLife() > 0) {
				if (isCollideInLeftTop(bullet, doubleCannon)) {
					doubleCannon.setEnemyLife(doubleCannon.getEnemyLife()
							- bullet.getDamage());
					world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
							+ (15 << 8), 0, 0);
					isCollide = true;
					
					if (doubleCannon.getEnemyLife() <= 0) {
						BattlePlaneActor.iScore += 300;
					}
				}
			}

			// 判断与圆炮的碰撞
			for (int cCannonIdx = 0; cCannonIdx < 2; cCannonIdx++) {
				if (cirlceCannon[cCannonIdx].getEnemyLife() > 0) {
					if (isCollideInLeftTop(bullet, cirlceCannon[cCannonIdx])) {
						cirlceCannon[cCannonIdx].setEnemyLife(cirlceCannon[cCannonIdx]
										.getEnemyLife()
										- bullet.getDamage());

						world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
								+ (15 << 8), 0, 0);
						isCollide = true;

						if (cirlceCannon[cCannonIdx].getEnemyLife() <= 0) {
							BattlePlaneActor.iScore += 500;
						}
					}
				}
			}

			// 判断与BOSS的碰撞
			if (isCollideInLeftTop(bullet, bossCannon)) {
				bossCannon.setEnemyLife(bossCannon.getEnemyLife()
						- bullet.getDamage());

				world.newBullet(1, bullet.getIPosX(), bullet.getIPosY()
						+ (15 << 8), 0, 0);
				isCollide = true;

				if (bossCannon.getEnemyLife() <= 0) {
					BattlePlaneActor.iScore += 1000;
				}
			}

			break;
		}
	}
	
	public void isCollideWithBoss() {
		switch (BOSS_STATE) {
		case GameConstant.STATE_BOSS_NORMAL_FIGHT:
			artillery.setEnemyLife(artillery.getEnemyLife() - 4);

			if (artillery.getEnemyLife() <= 0) {
				BattlePlaneActor.iScore += 100;
			}

			for (int i = 0; i < 4; i++) {
				if (smallCannon[i].getEnemyLife() > 0) {
					smallCannon[i]
							.setEnemyLife(smallCannon[i].getEnemyLife() - 4);

					if (smallCannon[i].getEnemyLife() <= 0) {
						BattlePlaneActor.iScore += 50;
					}
				}
			}
			break;
		case GameConstant.STATE_BOSS_CRAZY_FIGHT:
			for (int cannonIdx = 4; cannonIdx < 6; cannonIdx++) {
				if (smallCannon[cannonIdx].getEnemyLife() > 0) {
					smallCannon[cannonIdx].setEnemyLife(smallCannon[cannonIdx]
							.getEnemyLife() - 4);

					if (smallCannon[cannonIdx].getEnemyLife() <= 0) {
						BattlePlaneActor.iScore += 50;
					}
				}
			}

			if (doubleCannon.getEnemyLife() > 0) {
				doubleCannon.setEnemyLife(doubleCannon.getEnemyLife() - 4);
				if (doubleCannon.getEnemyLife() <= 0) {
					BattlePlaneActor.iScore += 300;
				}
			}

			for (int cCannonIdx = 0; cCannonIdx < 2; cCannonIdx++) {
				if (cirlceCannon[cCannonIdx].getEnemyLife() > 0) {
					cirlceCannon[cCannonIdx].setEnemyLife(cirlceCannon[cCannonIdx]
									.getEnemyLife() - 4);

					if (cirlceCannon[cCannonIdx].getEnemyLife() <= 0) {
						BattlePlaneActor.iScore += 500;
					}
				}
			}

			bossCannon.setEnemyLife(bossCannon.getEnemyLife() - 4);
			if (bossCannon.getEnemyLife() <= 0) {
				BattlePlaneActor.iScore += 1000;
			}
			break;
		}
	}

	public void clean() {
		// 清除小炮对象
		for (int sIdx = 0; sIdx < smallCannon.length; sIdx++) {
			smallCannon[sIdx] = null;
		}
		smallCannon = null;

		// 清除大炮
		artillery = null;

		// 清除双管炮
		doubleCannon = null;

		// 清除圆炮
		for (int cIdx = 0; cIdx < cirlceCannon.length; cIdx++) {
			cirlceCannon[cIdx] = null;
		}
		cirlceCannon = null;

		// 清除boss炮
		bossCannon = null;

		xSpeed = null;
		ySpeed = null;
		xCirlceSpeed = null;
		yCirlceSpeed = null;
	}

	private CImage bossAirship;
	private Cannon[] smallCannon; // 小炮
	private Cannon artillery; // 大炮
	private Cannon doubleCannon; // 双管炮
	private Cannon[] cirlceCannon; // 圆炮
	private Cannon bossCannon; // boss炮
	private int bulletTimes = 30; // 子弹发射记数
	private int[] xSpeed; // 子弹X轴移动的速度
	private int[] ySpeed; // 子弹Y轴移动的速度
	private int[] xCirlceSpeed; //画圆子弹X轴移动的速度
	private int[] yCirlceSpeed; //画圆子弹Y轴移动的速度
	//private World world;
	private GameScreen gameScreen;
	//private BattlePlaneActor planeActor;
}

⌨️ 快捷键说明

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