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

📄 kingcanvas.java

📁 一个J2ME的游戏,有源程序.是原创!适合S60的176*208的规格.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:

	public void drawGameOver(Graphics g) {
		if (BS.bFlagBossDie == true) { // 游戏过关画笔
			if (TimeOrderCounter <= 52) {
				g.fillRect(0, 0, TimeOrderCounter << 1, SCREEN_HEIGHT);
			} else if (TimeOrderCounter < 110) {
				g.setColor(0, 0, 0);
				g.fillRect(0, 0, SCREEN_WIDTH >> 1, SCREEN_HEIGHT);
				g.setColor(255, 255, 255);
				g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
						Font.SIZE_LARGE));
				g.drawString(" 恭 喜 ", (SCREEN_WIDTH >> 1) - 40,
						TimeOrderCounter - 52, 65);
				g.drawString(" 过 关 ", (SCREEN_WIDTH >> 1) - 40, SCREEN_HEIGHT
						+ 52 - TimeOrderCounter, 65);
			}
		} else { // 游戏失败画笔
			if (TimeOrderCounter <= 52) {
				g.fillRect(0, 0, SCREEN_WIDTH, TimeOrderCounter << 1);
				g.fillRect(0, SCREEN_HEIGHT - (TimeOrderCounter << 1),
						SCREEN_WIDTH, TimeOrderCounter << 1);
			} else if (TimeOrderCounter < 110) {
				clearScreen(g, 0, 0, 0);
				g.setColor(255, 255, 255);
				g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
						Font.SIZE_LARGE));
				g.drawString(" 游 戏 ", TimeOrderCounter - 53,
						SCREEN_HEIGHT >> 1, 65);
				g.drawString(" 结 束 ", SCREEN_WIDTH + 53 - TimeOrderCounter,
						SCREEN_HEIGHT >> 1, 65);
			}
		}
	}

	/**
	 * 游戏退出画笔
	 */

	public void drawExit(Graphics g) {
	}

	/**
	 * 游戏暂停画笔
	 */

	public void drawPause(Graphics g) {
		drawPauseAction(g);
	}

	/**
	 * 游戏功能选项菜单画笔
	 */

	public void drawOption(Graphics g) {
		drawOptionMenu(g);
	}

	/**
	 * 游戏关于画笔
	 */

	public void drawAbout(Graphics g) {
		g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN,
				Font.SIZE_SMALL));
		AT.draw(g);
	}

	/**
	 * 游戏帮助画笔
	 */

	public void drawHelp(Graphics g) {
		g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN,
				Font.SIZE_SMALL));
		AT.draw(g);
	}

	/**
	 * 游戏进行画笔
	 */

	public void drawPlay(Graphics g) {

		drawMoveSea(g);

		// clearScreen(g, 0, 0, 0);

		if (bFlagIslandAndWarshipDisplay == false) {
			drawIsland_1(g);
			drawIsland_2(g);
			drawWarship(g);
		} else {
			drawWarningPrompt(g);
		}

		BS.drawMoveBoss(g);

		// drawCloud_1(g);
		drawCloud_2(g);

		for (byte i = 0; i < SP.length; i++) {
			SP[i].drawEnemySmallPlane(g);
		}

		for (byte i = 0; i < OP.length; i++) {
			OP[i].drawEnemyOtherPlane(g);
		}

		if (bFlagLeadingPlaneDisplay == false) {
			drawleadingPlane(g);
		}

		drawLeadingPlaneMoveExplosion(g);
		drawLeadingPlaneBullets(g);

		for (byte i = 0; i < PS.length; i++) {
			PS[i].drawPlaneSbomb(g);
		}

		drawleadingPlaneIcon(g);
		drawLeadingPlaneHP(g);
		if (bFlagLeadingPlaneHPchangeDisplay == true) {
			drawLeadingPlaneHPframe(g);
			bFlagLeadingPlaneHPchangeDisplay = false;
		}
		drawScoreCounter(g);
		drawBomb(g);
		if (!isDoubleBuffered()) {
			renderWorld(osg);
			g.drawImage(osb, 0, 0, Tools.GRAPHICS_TOP_LEFT);
		} else {
			renderWorld(g);
		}

		// drawHPFrame(g);

	}

	/**
	 * 游戏主角飞机选择菜单画笔
	 */

	public void drawMain(Graphics g) {
		clearScreen(g, 0, 0, 0);
		LP.drawLeadingPlaneMenu(g);
	}

	/**
	 * 游戏初始化画笔
	 */

	public void drawInit(Graphics g) {
		clearScreen(g, 0, 0, 0);
		drawResourceload(g);
	}

	/**
	 * 游戏主菜单画笔
	 */

	public void drawLogo(Graphics g) {
		clearScreen(g, 0, 0, 0);
		g.drawImage(imagelogo1, 0, 0, Graphics.TOP | Graphics.LEFT);
		drawMainOption(g);
		clearClip(g);
	}

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

	public static void Brush(Graphics g, Image photo, int x, int y, int width,
			int height, int col, int row) {
		g.setClip(x, y, width, height);
		g.drawImage(photo, x - row * width, y - col * height, Graphics.TOP
				| Graphics.LEFT);
		clearClip(g);
	}

	// ------------------------------------------------------ 一级画笔

	/**
	 * 移动背景海画笔
	 */

	public void drawMoveSea(Graphics g) {
		drawSea(g);
		SeaMoveCounter--;
		clearClip(g);
	}

	/**
	 * 背景海画笔
	 */

	public void drawSea(Graphics g) {
		for (byte i = 0; i < 11; i++) {
			if (SeaMoveCounter > -15) {
				for (byte j = 0; j < 13; j++) {
					g.setClip(Sea_X, Sea_Y, p16width, p16height);
					g.drawImage(imageSea, Sea_X, Sea_Y - SeaNumber * p16height
							- SeaMoveCounter, Graphics.TOP | Graphics.LEFT);
					Sea_Y += p16height;
				}
				Sea_Y = 0;
				Sea_X += p16width;
			} else {
				SeaMoveCounter = 0;
			}
		}
		Sea_X = 0;
	}

	/**
	 * 海岛_1画笔
	 */

	public void drawIsland_1(Graphics g) {
		Brush(g, imageIsland, Island1_X, Island1_Y, imageIsland.getWidth(),
				imageIsland.getHeight() / 3, IslandNumber1, 0);
	}

	/**
	 * 海岛_2画笔
	 */

	public void drawIsland_2(Graphics g) {
		Brush(g, imageIsland, Island2_X, Island2_Y, imageIsland.getWidth(),
				imageIsland.getHeight() / 3, IslandNumber2, 0);
	}

	/**
	 * 小军舰画笔
	 */

	public void drawWarship(Graphics g) {
		Brush(g, imageWarship, Warship_X, Warship_Y, imageWarship.getWidth(),
				imageWarship.getHeight(), 0, 0);
	}

	/**
	 * 白云_1画笔
	 */

	public void drawCloud_1(Graphics g) {
		Brush(g, imageCloud, Cloud1_X, Cloud1_Y, imageCloud.getWidth(),
				imageCloud.getHeight(), 0, 0);
	}

	/**
	 * 白云_2画笔
	 */

	public void drawCloud_2(Graphics g) {
		Brush(g, imageCloud, Cloud2_X, Cloud2_Y, imageCloud.getWidth(),
				imageCloud.getHeight(), 0, 0);
	}

	/**
	 * 主角飞机HP框画笔
	 */

	public void drawHPFrame(Graphics g) {
		Brush(g, imageHPFrame, 2, 187, imageHPFrame.getWidth(), imageHPFrame
				.getHeight(), 0, 0);
	}

	/**
	 * 主角飞机画笔
	 */

	public void drawleadingPlane(Graphics g) {
		Brush(g, imageLeadingPlane, LeadingPlane_X, LeadingPlane_Y, p24width,
				p24height, LeadingPlaneNumber, 0);
	}

	/**
	 * 主角飞机爆炸画笔
	 */

	public void drawLeadingPlaneExplosion(Graphics g) {
		Brush(g, imageLeadingPlaneExplosion, LeadingPlaneExplosion_X,
				LeadingPlaneExplosion_Y, p24width, p24height,
				LeadingPlaneExplosionNumber, 0);
	}

	/**
	 * 主角飞机子弹画笔
	 */

	public void drawLeadingPlaneBullets(Graphics g) {
		if (bFlagLeadingPlaneBulletsDisplay == true) {
			for (byte i = 0; i < bulletsUP.length; i++) {
				bulletsUP[i].drawImage(g);
			}
			if (LeadingPlaneType == 1 || LeadingPlaneType == 2) {
				for (byte i = 0; i < bulletsLEFTUP.length; i++) {
					bulletsLEFTUP[i].drawImage(g);
				}
				for (byte i = 0; i < bulletsRIGHTUP.length; i++) {
					bulletsRIGHTUP[i].drawImage(g);
				}
			}
		}
	}

	/**
	 * 友军轰炸宝画笔
	 */

	public void drawBomb(Graphics g) {
		for (byte i = 0; i < BombCounter; i++) {
			Brush(g, imagelogo1, Bomb_X, Bomb_Y, imagelogo1.getWidth(),
					p16height, 1, 0);
			Bomb_X -= 10;
		}
		Bomb_X = 163;
	}

	/**
	 * 主角飞机图标画笔
	 */

	public void drawleadingPlaneIcon(Graphics g) {
		for (byte i = 0; i < leadingPlaneIconCounter; i++) {
			Brush(g, imageLeadingPlaneIcon, LeadingPlaneIcon_X,
					LeadingPlaneIcon_Y, p16width, p16height, 0, 0);
			LeadingPlaneIcon_X += 17;
		}
		LeadingPlaneIcon_X = 0;
	}

	/**
	 * 主角飞机血量画笔
	 */

	public void drawLeadingPlaneHP(Graphics g) {
		g.setColor(255, 255, 255);
		g.drawRect(10, 193, 25, 4);
		g.setColor(255, 0, 0);
		g.fillRect(11, 194, LeadingPlaneHP, 3);
	}

	/**
	 * 成绩计数画笔
	 */

	public void drawScoreCounter(Graphics g) {
		g.setColor(255, 255, 255);
		g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_UNDERLINED,
				Font.SIZE_MEDIUM));
		g.drawString(String.valueOf(ScoreCounter), 172, 17, Graphics.RIGHT
				| Graphics.BOTTOM);
	}

	// ------------------------------------------------------ 二级画笔

	/**
	 * 主角飞机血量边框画笔
	 */

	public void drawLeadingPlaneHPframe(Graphics g) {
		g.setColor(255, 255, 255);
		g.drawRect(10, 193, 25, 4);
		if (LeadingPlaneHPcounter > 0 || LeadingPlaneHP > 0) {
			drawLeadingPlaneMoveHP(g);
		} else {
			LeadingPlaneHPcounter = 0;
		}
	}

	/**
	 * 主角飞机血量变化画笔
	 */

	public void drawLeadingPlaneMoveHP(Graphics g) {
		g.setColor(255, 0, 0);
		g.fillRect(11, 194, LeadingPlaneHP, 3);
		LeadingPlaneHPcounter++;
		switch (BulletsPlantState) {
		case 1:
			LeadingPlaneHP--;
			break;
		case 2:
			LeadingPlaneHP -= 3;
			break;
		}
		if (LeadingPlaneHP < 0) {
			InitBullets();
			bFlagLeadingPlaneHPchangeDisplay = false;
			bFlagLeadingPlaneExplosionDisplay = true;
			bFlagLeadingPlaneDisplay = true;
			LeadingPlaneExplosion_X = LeadingPlane_X;
			LeadingPlaneExplosion_Y = LeadingPlane_Y;
			tempX = LeadingPlane_X;
			LeadingPlane_Y += 96;
			tempY = LeadingPlane_Y;
		}
	}

	/**
	 * 主角飞机爆炸变化画笔
	 */

	public void drawLeadingPlaneMoveExplosion(Graphics g) {
		if (bFlagLeadingPlaneExplosionDisplay == true) {
			drawLeadingPlaneExplosion(g);
			if (LeadingPlaneExplosionNumber < 7) {
				LeadingPlaneExplosionNumber++;
			} else {
				LeadingPlaneExplosionNumber = 0;
			}
			bFlagLeadingPlaneExplosionDisplay = false;
		}
	}

	/**
	 * 暂停动作变化画笔
	 */

	public void drawPauseAction(Graphics g) {
		bFlagPauseMenuDisplay = true;

		g.setColor(0, 0, 0);
		g.fillRoundRect((SCREEN_WIDTH >> 2) - 5, (SCREEN_HEIGHT >> 1) - 20,
				(SCREEN_WIDTH >> 1) + 10, 39, 5, 5);
		g.setColor(255, 255, 255);
		g.drawRoundRect((SCREEN_WIDTH >> 2) - 3, (SCREEN_HEIGHT >> 1) - 17,
				(SCREEN_WIDTH >> 1) + 10 - 5, 32, 5, 5);
		g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
				Font.SIZE_SMALL));

		if (bFlagStopMenu == false) {
			g.setColor(255, 255, 255);
			g.fillRoundRect((SCREEN_WIDTH >> 2), (SCREEN_HEIGHT >> 1) - 14,
					(SCREEN_WIDTH >> 1), 13, 0, 0);
		} else {
			g.setColor(255, 255, 255);
			g.fillRoundRect((SCREEN_WIDTH >> 2), (SCREEN_HEIGHT >> 1),
					(SCREEN_WIDTH >> 1), 13, 0, 0);
		}

		g.setColor(ColorCounter, ColorCounter, ColorCounter);
		g.drawString("返回游戏", (SCREEN_WIDTH >> 1) - 24,
				(SCREEN_HEIGHT >> 1) - 13, 0);
		g.drawString("回主菜单", (SCREEN_WIDTH >> 1) - 24,
				(SCREEN_HEIGHT >> 1) + 1, 0);
		if (ColorCounter <= 240) {
			ColorCounter += 15;
		} else {
			ColorCounter = 0;
		}

	}

	/**
	 * 警告提示画笔
	 */

	public void drawWarningPrompt(Graphics g) {
		if (timeCounter <= 150) {
			timeCounter++;
			g.setColor(ColorCounter, 0, 0);
			g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
					Font.SIZE_SMALL));
			g.drawString(" 警 告! 战 舰 接 近 中 ....  ", 24, SCREEN_HEIGHT >> 1, 0);
			if (ColorCounter <= 240) {
				ColorCounter += 15;
			} else {
				ColorCounter = 0;
			}
		}
	}

	/**
	 * 游戏主菜单选择变化画笔
	 */

	public void drawMainOption(Graphics g) {
		switch (MainOptionCounter) {
		case 90:
			g.setClip(50, MainOptionCounter, 80, 14);
			g.drawImage(imagelogo2, 51, MainOptionCounter, Graphics.TOP
					| Graphics.LEFT);
			StateCounter = 1;
			break;
		case 104:
			g.setClip(50, MainOptionCounter, 80, 14);
			g.drawImage(imagelogo2, 51, MainOptionCounter - 14, Graphics.TOP
					| Graphics.LEFT);
			StateCounter = 2;
			break;
		case 118:
			g.setClip(50, MainOptionCounter, 80, 14);
			g.drawImage(imagelogo2, 51, MainOptionCounter - 28, Graphics.TOP
					| Graphics.LEFT);
			StateCounter = 3;
			break;
		case 132:
			g.setClip(50, MainOptionCounter, 80, 14);
			g.drawImage(imagelogo2, 51, MainOptionCounter - 44, Graphics.TOP
					| Graphics.LEFT);
			StateCounter = 4;
			break;
		case 146:
			g.setClip(50, MainOptionCounter, 80, 14);
			g.drawImage(imagelogo2, 51, MainOptionCounter - 58, Graphics.TOP
					| Graphics.LEFT);
			StateCounter = 5;
			break;
		}

	}

	/**
	 * 游戏功能选项变化画笔
	 */

	public void drawOptionMenu(Graphics g) {
		g.setColor(0, 0, 0);
		g.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
		g.setColor(255, 255, 255);
		g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
				Font.SIZE_LARGE));
		g.drawString("  ----- 游 戏 选 项-----", 5, 15, 0);
		g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
				Font.SIZE_LARGE));
		g.setColor(255, 255, 255);
		g.fillRect(0, 188, SCREEN_WIDTH, 20);
		g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
				Font.SIZE_MEDIUM));
		g.setColor(ColorCounter, ColorCounter, ColorCounter);
		g.drawString(" 返 回 ", 132, 190, 0);
		if (ColorCounter <= 240) {
			ColorCounter += 15;
		} else {
			ColorCounter = 0;

⌨️ 快捷键说明

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