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

📄 kingcanvas.java

📁 一个J2ME的游戏,有源程序.是原创!适合S60的176*208的规格.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
							bulletsLEFTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
							if (BS.BatteryHP[j] > 0) {
								switch (LeadingPlaneType) {
								case 0:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 5;
										break;
									case 1:
										BS.BatteryHP[j] -= 7;
										break;
									case 2:
										BS.BatteryHP[j] -= 9;
										break;
									}
									break;
								case 1:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j]--;
										break;
									case 1:
										BS.BatteryHP[j] -= 3;
										break;
									case 2:
										BS.BatteryHP[j] -= 5;
										break;
									}
									break;
								case 2:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 2;
										break;
									case 1:
										BS.BatteryHP[j] -= 4;
										break;
									case 2:
										BS.BatteryHP[j] -= 6;
										break;
									}
									break;
								}
							} else {
								BS.bFlagBattery_HP[j] = true;
							}
							break;
						}
					}
				}

				for (byte j = 4; j < 8; j++) {
					if (BS.bFlagBattery_HP[j] == false) {
						if (bulletsLEFTUP[i].isRam(BS.Battery_X[j],
								BS.Battery_Y[j], Boss.SmallBattery.getWidth(),
								Boss.SmallBattery.getHeight() >> 3)) {
							bulletsLEFTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
							if (BS.BatteryHP[j] > 0) {
								switch (LeadingPlaneType) {
								case 0:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 5;
										break;
									case 1:
										BS.BatteryHP[j] -= 7;
										break;
									case 2:
										BS.BatteryHP[j] -= 9;
										break;
									}
									break;
								case 1:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j]--;
										break;
									case 1:
										BS.BatteryHP[j] -= 3;
										break;
									case 2:
										BS.BatteryHP[j] -= 5;
										break;
									}
									break;
								case 2:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 2;
										break;
									case 1:
										BS.BatteryHP[j] -= 4;
										break;
									case 2:
										BS.BatteryHP[j] -= 6;
										break;
									}
									break;
								}
							} else {
								BS.bFlagBattery_HP[j] = true;
							}
							break;
						}
					}
				}
				bulletsLEFTUP[i].BulletsUpdate();
			}

			// 右上方主飞机发射子弹

			for (byte i = 0; i < bulletsRIGHTUP.length; i++) {
				for (byte j = 0; j < SP.length; j++) {
					if (bulletsRIGHTUP[i].isRam(SP[j].PlaneX, SP[j].PlaneY,
							SmallPlane.Plane.getWidth() - 4, SmallPlane.Plane
									.getHeight() / 6)) {
						bulletsRIGHTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
						SP[j].procBeHurt();
						break;
					}

				}

				for (byte j = 0; j < OP.length; j++) {
					if (bulletsRIGHTUP[i].isRam(OP[j].PlaneX, OP[j].PlaneY + 1,
							OtherPlane.Plane.getWidth() - 4, OtherPlane.Plane
									.getHeight() - 2)) {
						bulletsRIGHTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
						OP[j].procBeHurt();
						break;
					}

				}

				for (byte j = 0; j < 4; j++) {
					if (BS.bFlagBattery_HP[j] == false) {
						if (bulletsRIGHTUP[i].isRam(BS.Battery_X[j] + 4,
								BS.Battery_Y[j] + 4,
								Boss.BigBattery.getWidth() - 8,
								(Boss.BigBattery.getHeight() >> 3) - 8)) {
							bulletsRIGHTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
							if (BS.BatteryHP[j] > 0) {
								switch (LeadingPlaneType) {
								case 0:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 5;
										break;
									case 1:
										BS.BatteryHP[j] -= 7;
										break;
									case 2:
										BS.BatteryHP[j] -= 9;
										break;
									}
									break;
								case 1:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j]--;
										break;
									case 1:
										BS.BatteryHP[j] -= 3;
										break;
									case 2:
										BS.BatteryHP[j] -= 5;
										break;
									}
									break;
								case 2:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 2;
										break;
									case 1:
										BS.BatteryHP[j] -= 4;
										break;
									case 2:
										BS.BatteryHP[j] -= 6;
										break;
									}
									break;
								}
							} else {
								BS.bFlagBattery_HP[j] = true;
							}
							break;
						}
					}
				}

				for (byte j = 4; j < 8; j++) {
					if (BS.bFlagBattery_HP[j] == false) {
						if (bulletsRIGHTUP[i].isRam(BS.Battery_X[j],
								BS.Battery_Y[j], Boss.SmallBattery.getWidth(),
								Boss.SmallBattery.getHeight() >> 3)) {
							bulletsRIGHTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
							if (BS.BatteryHP[j] > 0) {
								switch (LeadingPlaneType) {
								case 0:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 5;
										break;
									case 1:
										BS.BatteryHP[j] -= 7;
										break;
									case 2:
										BS.BatteryHP[j] -= 9;
										break;
									}
									break;
								case 1:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j]--;
										break;
									case 1:
										BS.BatteryHP[j] -= 3;
										break;
									case 2:
										BS.BatteryHP[j] -= 5;
										break;
									}
									break;
								case 2:
									switch (BulletsPowerCounter) {
									case 0:
										BS.BatteryHP[j] -= 2;
										break;
									case 1:
										BS.BatteryHP[j] -= 4;
										break;
									case 2:
										BS.BatteryHP[j] -= 6;
										break;
									}
									break;
								}
							} else {
								BS.bFlagBattery_HP[j] = true;
							}
							break;
						}
					}
				}

				bulletsRIGHTUP[i].BulletsUpdate();
			}
		}
	}

	/**
	 * 判断是否播放背景音乐处理方法
	 */

	public void bFlagMusic() {
		if (isMusic == true) {
			if (MusicTest == 0) {
				PM.replayMusic(Music);
				MusicTest++;
			}
		} else {
			PM.closeMusic();
		}
	}

	/**
	 * 雪调用变化处理方法
	 */

	public void Snow() {
		try {
			if (wind > 0) {
				if (count++ > 5) {
					wind--;
					count = 0;
				}
			}
			if (wind < 0) {
				if (count++ > 5) {
					wind++;
					count = 0;
				}
			}
			if (pra == 1)
				Tools.updatesnow(wind);

			if (System.currentTimeMillis() - lastCPSTime > 1000) {
				cps = cyclesThisSecond;
				cyclesThisSecond = 0;
			} else
				cyclesThisSecond++;
			timeSinceStart = System.currentTimeMillis() - cycleStartTime;
			if (timeSinceStart < MS_PER_FRAME) {
				synchronized (this) {
					wait(MS_PER_FRAME - timeSinceStart);
				}
			} else
				Thread.yield();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 友军轰炸碰撞处理方法
	 */

	public void SbombCollide() {

		for (byte i = 0; i < PS.length; i++) {

			// ------------------- 炸弹与敌人小飞机的碰撞
			for (byte j = 0; j < SP.length; j++) {
				if (isRam(SP[j].PlaneX, SP[j].PlaneY, SmallPlane.Plane
						.getWidth(), SmallPlane.Plane.getHeight() / 6,
						PS[i].PlaneArticle_X, PS[i].PlaneArticle_Y,
						PlaneArticle.getWidth(), PlaneArticle.getHeight() / 3)) {
					ScoreCounter += 2;
					SP[j].Explosion_X = SP[j].PlaneX;
					SP[j].Explosion_Y = SP[j].PlaneY;
					SP[j].bFlagSmallPlaneHP = true;
				}
			}

			// ------------------- 炸弹与敌人中型飞机的碰撞
			for (byte j = 0; j < OP.length; j++) {
				if (isRam(OP[j].PlaneX, OP[j].PlaneY, OtherPlane.Plane
						.getWidth(), OtherPlane.Plane.getHeight(),
						PS[i].PlaneArticle_X, PS[i].PlaneArticle_Y,
						PlaneArticle.getWidth(), PlaneArticle.getHeight() / 3)) {
					ScoreCounter += 4;
					OP[j].Explosion_X = OP[j].PlaneX + 6;
					OP[j].Explosion_Y = OP[j].PlaneY + 1;
					OP[j].PlaneArticle_X = OP[j].Explosion_X + 8;
					OP[j].PlaneArticle_Y = OP[j].Explosion_Y + 4;
					OP[j].bFlagOtherPlaneHP = true;
				}
			}

			// ------------------- 炸弹与BOSS大炮塔的碰撞
			for (byte j = 0; j < 4; j++) {
				if (isRam(BS.Battery_X[j], BS.Battery_Y[j], Boss.BigBattery
						.getWidth(), Boss.BigBattery.getHeight() >> 3,
						PS[i].PlaneArticle_X, PS[i].PlaneArticle_Y,
						PlaneArticle.getWidth(), PlaneArticle.getHeight() / 3)) {
					BS.BatteryHP[j] -= 32;
				}
			}

			// ------------------- 炸弹与BOSS小炮塔的碰撞
			for (byte j = 4; j < 8; j++) {
				if (isRam(BS.Battery_X[j], BS.Battery_Y[j], Boss.SmallBattery
						.getWidth(), Boss.SmallBattery.getHeight() >> 3,
						PS[i].PlaneArticle_X, PS[i].PlaneArticle_Y,
						PlaneArticle.getWidth(), PlaneArticle.getHeight() / 3)) {
					BS.BatteryHP[j] -= 32;
				}
			}
		}
	}

	/**
	 * 主角飞机子弹威力处理方法
	 */

	public void BulletsPower() {
		InitBullets();
		if (BulletsPowerCounter < 2)
			BulletsPowerCounter++;
	}

	/**
	 * 游戏功能选择菜单状态比较处理方法
	 */

	public void MenuKeyCompare() {
		switch (OptionMenu1) {
		case 0:
			TimeOrderCounter = 0;
			OptionMenu2 = 1;
			OptionMenu3 = 0;
			break;
		case 1:
			TimeOrderCounter = 0;
			OptionMenu2 = 2;
			OptionMenu3 = 0;
			break;
		case 2:
			TimeOrderCounter = 0;
			OptionMenu2 = 3;
			OptionMenu3 = 0;
			break;
		}
	}

	private void initResources() {
		try {
			// 是否支持双缓存
			if (!isDoubleBuffered()) {
				osb = Image.createImage(SCREEN_WIDTH, SCREEN_HEIGHT);
				osg = osb.getGraphics();
			}
			for (int i = 0; i < 50; i++)// 初始化粒子
			{
				Tools.posx[i] = Tools.getRand(0, SCREEN_WIDTH);
				Tools.posy[i] = Tools.getRand(0, SCREEN_HEIGHT);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private final void renderWorld(Graphics graphics) {
		if (pra == 1)
			Tools.drawSnow(graphics);
	}

	/**
	 * 游戏初始化进度加载处理方法
	 */

	public void Resourceload() {
		try {
			Thread currentThread = Thread.currentThread();
			while (currentThread == thread) {
				startTime = (int) System.currentTimeMillis();
				repaint(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
				gaugeCnt += MainCanvasInterval;
				if (imagelogo2 != null) {
					MainCanvasInterval += 1;
				}
				if (gaugeCnt >= MAINCANVAS_END) {
					if (imagelogo2 == null) {
						gaugeCnt -= MainCanvasInterval;
					} else {
						gaugeCnt = MAINCANVAS_END;
						loadMainCanvasOver = true;
						break;
					}
				}
				endTime = (int) System.currentTimeMillis();
				if ((endTime - startTime) < FRAME_TIME) {
					Thread.sleep(FRAME_TIME - (endTime - startTime));
				}
			}
		} catch (InterruptedException ie) {
			System.out.println(ie.toString());
		}
	}

	// -------------------------------------------------

	public static void clearClip(Graphics g) {
		g.setClip(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
	}

	public static void clearScreen(Graphics g, int R, int G, int B) {
		g.setColor(R, G, B);
		g.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
	}

	public int GetRandom(int x) {
		return (Math.abs(random.nextInt()) % x);
	}

	/**
	 * 碰撞处理方法
	 */

	public boolean isRam(int tx, int ty, int tw, int th, int rx, int ry,
			int rw, int rh) {
		if (tx + tw <= rx || tx >= rx + rw || ty + th <= ry || ty >= ry + rh)
			return false;
		return true;
	}

	/**
	 * 游戏主菜单图片加载处理方法
	 */

	static void LoadLogoImage() {
		try {
			imagelogo1 = Image.createImage("/res/picture/logo.png");
			imagelogo2 = Image.createImage("/res/picture/hn.png");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 游戏进行部分图片加载处理方法
	 */

	static void LoadplayImage() {
		try {
			imageWarship = Image.createImage("/res/picture/Warship_.png");
			imageIsland = Image.createImage("/res/picture/island_.png");
			imageCloud = Image.createImage("/res/picture/Cloud_.png");
			imageSea = Image.createImage("/res/picture/sea_.png");
			imageLeadingPlaneExplosion = Image
					.createImage("/res/picture/leadingbom_.png");
			imagelogo1 = Image.createImage("/res/picture/treasure.png");
			imageHPFrame = Image.createImage("/res/picture/HpFrame.png");

			// -----------------------------------友军轰炸相关图片

			Plane = Image.createImage("/res/picture/bigplane_1.png");
			PlaneExplosion = Image.createImage("/res/picture/leadingbom_.png");
			PlaneArticle = Image.createImage("/res/picture/treasure-1.png");

			// -----------------------------------

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void DelplayImage() {
		imageWarship = null;
		imageIsland = null;
		imageCloud = null;
		imageSea = null;
		imageLeadingPlaneExplosion = null;
		imagelogo1 = null;

		Boss.Boss = null;
		Boss.BigBattery = null;
		Boss.SmallBattery = null;
		Boss.BatteryExplosion = null;
		Boss.BigExplosion = null;

		OtherPlane.Plane = null;
		OtherPlane.PlaneExp

⌨️ 快捷键说明

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