📄 kingcanvas.java
字号:
}
}
if (OptionMenu2 == 2 || OptionMenu2 == 3) {
if (OptionMenu3 < 2) {
OptionMenu3++;
} else {
OptionMenu3 = 0;
}
}
keyCode = KB_NONE;
break;
case KB_COMMAND_RIGHT:
System.gc();
LoadLogoImage();
keyCode = KB_NONE;
gameState = GS_LOGO;
break;
}
}
/**
* 游戏帮助与关于键控处理方法
*/
public void HelpAndAboutKeyOption() {
switch (keyCode) {
case KB_UP:
AT.up();
break;
case KB_DOWN:
AT.down();
break;
case KB_COMMAND_RIGHT:
System.gc();
LoadLogoImage();
keyCode = KB_NONE;
gameState = GS_LOGO;
break;
}
}
/**
* 游戏暂停键控处理方法
*/
public void PauseKeyOption() {
if (bFlagPauseMenuDisplay == true) {
switch (keyCode) {
case KB_UP:
bFlagStopMenu = false;
keyCode = KB_NONE;
break;
case KB_DOWN:
bFlagStopMenu = true;
keyCode = KB_NONE;
break;
case KB_CENTER:
if (bFlagStopMenu == false) {
gameState = GS_PLAY;
bFlagPauseMenuDisplay = false;
keyCode = KB_NONE;
break;
} else {
DelplayImage();
System.gc();
procInit();
LoadLogoImage();
bFlagPauseMenuDisplay = false;
if (bFlagMusic == false) {
Music = "/res/audio/hm-mmbnindoors.mid";
isMusic = true;
MusicTest = 0;
} else {
isMusic = false;
}
keyCode = KB_NONE;
gameState = GS_LOGO;
break;
}
}
}
}
/**
* 主角飞机键控处理方法
*/
public void LeadingPlaneKeyOption() {
pra = 1;
FireBullet();
LeadingPlaneNumber = 1;
switch (keyCode) {
case KB_CENTER:
if (bFlagSbombDouble == false) {
bFlagSbombDouble = true;
if (BombCounter > 0) {
BombCounter--;
bFlagArticle = 1;
PlaneSbombStem = 0;
for (byte i = 0; i < PS.length; i++) {
PS[i] = new PlaneSbomb(this, PlaneSbombStem);
PlaneSbombStem += 64;
}
}
}
keyCode = KB_NONE;
break;
case KB_UP:
if (LeadingPlane_Y <= 0)
LeadingPlane_Y = Stem;
LeadingPlaneNumber = 1;
LeadingPlane_Y -= Stem;
break;
case KB_DOWN:
if (LeadingPlane_Y >= SCREEN_HEIGHT - p24height - 10)
LeadingPlane_Y = SCREEN_HEIGHT - p24height - 10;
LeadingPlaneNumber = 1;
LeadingPlane_Y += Stem;
break;
case KB_LEFT:
if (LeadingPlane_X <= 0) {
LeadingPlane_X = 0;
LeadingPlaneNumber = 1;
} else {
LeadingPlaneNumber = 2;
LeadingPlane_X -= Stem;
}
wind = LP.windtemp;
count = 0;
break;
case KB_RIGHT:
if (LeadingPlane_X >= SCREEN_WIDTH - p24width) {
LeadingPlane_X = SCREEN_WIDTH - p24width;
LeadingPlaneNumber = 1;
} else {
LeadingPlaneNumber = 0;
LeadingPlane_X += Stem;
}
wind = -LP.windtemp;
count = 0;
break;
case KB_COMMAND_LEFT:
keyCode = KB_NONE;
gameState = GS_PAUSE;
break;
}
}
// ------------------------------------- 进程方法
/**
* 移动海岛处理方法
*/
public void MoveIsland() {
if (Island1_Y < SCREEN_HEIGHT) {
Island1_Y += 2;
} else {
if (IslandNumber1 < 3) {
IslandNumber1++;
} else {
IslandNumber1 = 0;
}
Island1_Y = -(imageIsland.getHeight() / 3);
Island1_X = GetRandom(144);
}
if (Island2_Y < SCREEN_HEIGHT) {
Island2_Y += 2;
} else {
if (IslandNumber2 < 3) {
IslandNumber2++;
} else {
IslandNumber2 = 0;
}
Island2_Y = -(imageIsland.getHeight() / 3);
Island2_X = GetRandom(144);
}
}
/**
* 移动小军舰处理方法
*/
public void MoveWarship() {
if (Warship_Y < SCREEN_HEIGHT) {
if (isRam(Warship_X, Warship_Y, imageWarship.getWidth(),
imageWarship.getHeight(), Island1_X, Island1_Y - 10,
imageIsland.getWidth(), imageIsland.getHeight() / 3)
|| isRam(Warship_X, Warship_Y, imageWarship.getWidth(),
imageWarship.getHeight(), Island2_X,
Island2_Y - 10, imageIsland.getWidth(), imageIsland
.getHeight() / 3)) {
Warship_Y += 2;
} else {
Warship_Y += 3;
}
} else {
Warship_Y = -imageWarship.getHeight();
Warship_X = GetRandom(160);
}
}
/**
* 移动云处理方法
*/
public void MoveCloud() {
if (Cloud1_Y < SCREEN_HEIGHT) {
Cloud1_Y += 3;
} else {
Cloud1_Y = 0 - imageCloud.getHeight();
Cloud1_X = GetRandom(144);
}
if (Cloud2_Y < SCREEN_HEIGHT) {
Cloud2_Y += 5;
} else {
Cloud2_Y = 0 - imageCloud.getHeight();
Cloud2_X = GetRandom(144);
}
}
/**
* 主角飞机子弹初始化处理方法
*/
public void InitBullets() {
bulletsUP = new LeadingPlaneBullets[7];
for (byte i = 0; i < bulletsUP.length; i++) {
bulletsUP[i] = new LeadingPlaneBullets();
}
if (LeadingPlaneType == 1 || LeadingPlaneType == 2) {
bulletsLEFTUP = new LeadingPlaneBullets[7];
for (byte i = 0; i < bulletsLEFTUP.length; i++) {
bulletsLEFTUP[i] = new LeadingPlaneBullets();
}
bulletsRIGHTUP = new LeadingPlaneBullets[7];
for (byte i = 0; i < bulletsRIGHTUP.length; i++) {
bulletsRIGHTUP[i] = new LeadingPlaneBullets();
}
}
}
/**
* 主角飞机发射子弹处理方法
*/
public void FireBullet() {
BulletsCounter++;
BulletsCounter %= 7;
if (bFlagLeadingPlaneDisplay == false) {
bFlagLeadingPlaneBulletsDisplay = true;
} else {
bFlagLeadingPlaneBulletsDisplay = false;
InitBullets();
}
bFlagKeyManyStroke = false;
if (BulletsCounter > 7) {
BulletsCounter = 0;
}
}
/**
* 主角飞机产生子弹处理方法
*/
public void GenerateBullet() {
if (LeadingPlaneType == 0) {
if (TimeOrderCounter % 1 == 0) {
for (byte i = 0; i < bulletsUP.length; i++) {
if (bulletsUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsUP[i].init(initBulletType + BulletsPowerCounter,
LeadingPlane_X + 4, LeadingPlane_Y - 5,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_UP);
break;
}
}
}
}
if (LeadingPlaneType == 1) {
if (TimeOrderCounter % 3 == 0) {
for (byte i = 0; i < bulletsUP.length; i++) {
if (bulletsUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsUP[i].init(initBulletType + BulletsPowerCounter,
LeadingPlane_X + 4, LeadingPlane_Y - 5,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_UP);
break;
}
}
for (byte i = 0; i < bulletsLEFTUP.length; i++) {
if (bulletsLEFTUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsLEFTUP[i].init(initBulletType
+ BulletsPowerCounter, LeadingPlane_X - 1,
LeadingPlane_Y,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_LEFTUP);
break;
}
}
for (byte i = 0; i < bulletsRIGHTUP.length; i++) {
if (bulletsRIGHTUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsRIGHTUP[i].init(initBulletType
+ BulletsPowerCounter, LeadingPlane_X + 9,
LeadingPlane_Y,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_RIGHTUP);
break;
}
}
}
}
if (LeadingPlaneType == 2) {
if (TimeOrderCounter % 3 == 0) {
for (byte i = 0; i < bulletsUP.length; i++) {
if (bulletsUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsUP[i].init(initBulletType + BulletsPowerCounter,
LeadingPlane_X + 4, LeadingPlane_Y - 5,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_UP);
break;
}
}
for (byte i = 0; i < bulletsLEFTUP.length; i++) {
if (bulletsLEFTUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsLEFTUP[i].init(initBulletType
+ BulletsPowerCounter, LeadingPlane_X - 2,
LeadingPlane_Y + 5,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_LEFT);
break;
}
}
for (byte i = 0; i < bulletsRIGHTUP.length; i++) {
if (bulletsRIGHTUP[i].BulletsState == LeadingPlaneBullets.BULLET_STATE_DIE) {
bulletsRIGHTUP[i].init(initBulletType
+ BulletsPowerCounter, LeadingPlane_X + 10,
LeadingPlane_Y + 5,
LeadingPlaneBullets.BULLET_SPEED_MIDDLE,
LeadingPlaneBullets.BULLET_DIR_RIGHT);
break;
}
}
}
}
}
/**
* 主角飞机子弹碰撞状态处理方法
*/
public void BulletsCollideState() {
// 上方主飞机发射子弹
for (byte i = 0; i < bulletsUP.length; i++) {
for (byte j = 0; j < SP.length; j++) {
if (bulletsUP[i].isRam(SP[j].PlaneX, SP[j].PlaneY,
SmallPlane.Plane.getWidth() - 4, SmallPlane.Plane
.getHeight() / 6)) {
bulletsUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
SP[j].procBeHurt();
break;
}
}
for (byte j = 0; j < OP.length; j++) {
if (bulletsUP[i].isRam(OP[j].PlaneX, OP[j].PlaneY + 1,
OtherPlane.Plane.getWidth() - 4, OtherPlane.Plane
.getHeight() - 2)) {
bulletsUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
OP[j].procBeHurt();
break;
}
}
for (byte j = 0; j < 4; j++) {
if (BS.bFlagBattery_HP[j] == false) {
if (bulletsUP[i].isRam(BS.Battery_X[j] + 4,
BS.Battery_Y[j] + 4,
Boss.BigBattery.getWidth() - 8, (Boss.BigBattery
.getHeight() >> 3) - 8)) {
bulletsUP[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 (bulletsUP[i].isRam(BS.Battery_X[j], BS.Battery_Y[j],
Boss.SmallBattery.getWidth(), Boss.SmallBattery
.getHeight() >> 3)) {
bulletsUP[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;
}
}
}
bulletsUP[i].BulletsUpdate();
}
// 左上方主飞机发射子弹
if (LeadingPlaneType == 1 || LeadingPlaneType == 2) {
for (byte i = 0; i < bulletsLEFTUP.length; i++) {
for (byte j = 0; j < SP.length; j++) {
if (bulletsLEFTUP[i].isRam(SP[j].PlaneX, SP[j].PlaneY,
SmallPlane.Plane.getWidth() - 4, SmallPlane.Plane
.getHeight() / 6)) {
bulletsLEFTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
SP[j].procBeHurt();
break;
}
}
for (byte j = 0; j < OP.length; j++) {
if (bulletsLEFTUP[i].isRam(OP[j].PlaneX, OP[j].PlaneY + 1,
OtherPlane.Plane.getWidth() - 4, OtherPlane.Plane
.getHeight() - 2)) {
bulletsLEFTUP[i].BulletsState = LeadingPlaneBullets.BULLET_STATE_DIE;
OP[j].procBeHurt();
break;
}
}
for (byte j = 0; j < 4; j++) {
if (BS.bFlagBattery_HP[j] == false) {
if (bulletsLEFTUP[i].isRam(BS.Battery_X[j] + 4,
BS.Battery_Y[j] + 4,
Boss.BigBattery.getWidth() - 8,
(Boss.BigBattery.getHeight() >> 3) - 8)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -