?? applet1.java
字號(hào):
catch (ArrayIndexOutOfBoundsException e) { }
break;
case 5: //P walks down
if (player[i].getImmortalCounter() < flashSpeed/2)
b.drawImage(p1[0],playerX,playerY,this);
try {
playerAY = player[i].toAbsY(playerY+pH/2);
if (((pMap[playerAX][player[i].toAbsY(playerY+pW+7+(int)(playerSpeed+0.5)-1)] <= 3 &&
pMap[player[i].toAbsX(playerX+pW+1)][player[i].toAbsY(playerY+pW+7+(int)(playerSpeed+0.5)-1)] <= 3) ||
(pMap[playerAX][player[i].toAbsY(playerY-(int)(playerSpeed+0.5))+1] <= 3 &&
pMap[player[i].toAbsX(playerX+pW+1)][player[i].toAbsY(playerY-(int)(playerSpeed+0.5))+1] <= 3)) &&
pMap[playerAX][playerAY] >= 0 &&
playerY+pH <= getHeight() - space) {
player[i].move();
checkItem(i);
}
else if (player[i].canKickBombs() && pMap[playerAX][player[i].toAbsY(playerY+pW+7+(int)(playerSpeed+0.5))] >= 30 && pMap[playerAX][playerAY+2] <= 3) {
pMap[playerAX][playerAY+1] = oldPMap[playerAX][playerAY+1];
moveBomb(playerAX,playerAY+1,4);
}
}
catch (ArrayIndexOutOfBoundsException e) { }
break;
case 6: //P stands still
if (player[i].getImmortalCounter() < flashSpeed/2)
b.drawImage(p1[4],playerX-2,playerY,this);
break;
case 7: //P wins
b.drawImage(p1[6],playerX,playerY,this);
break;
case 8: //P is stunned
b.drawImage(p1[5],playerX,playerY,this);
break;
}
try {
switch (i) {
case 0: b.drawString("P1", playerX+2,playerY); break;
case 1: b.drawString("P2", playerX+2,playerY); break;
case 2: b.drawString("P3", playerX+2,playerY); break;
case 3: b.drawString("P4", playerX+2,playerY); break;
}
}
catch (IllegalArgumentException e) { }
catch (NullPointerException e) { }
}
}
requestedPaint = true;
}
public void explodeBomb(int ID) { //Make a bomb explode
if (effectsAreOn)
soundEffect[1].play();
int playerID = bombs[ID].getPlayerID();
int bAX = bombs[ID].getAbsX();
int bAY = bombs[ID].getAbsY();
pMap[bAX][bAY] = oldPMap[bAX][bAY];
player[playerID].delBombPlaced();
bombs[ID].setExploded(true);
bombs[ID].setBomb(false);
bombs[ID].setDirection(0);
checkDirections(ID);
addExplosion(ID);
}
//public void checkMineDirections(int ID) { //Sets the X's and Y's of the mine's explosion
/*bombs[ID].setMaxRight(-1);
bombs[ID].setMaxLeft(-1);
bombs[ID].setMaxUp(-1);
bombs[ID].setMaxDown(-1);*/
/*int bAX = bombs[ID].getAbsX();
int bAY = bombs[ID].getAbsY();
boolean findMoreL = true;
boolean findMoreR = true;
boolean findMoreU = true;
boolean findMoreD = true;
boolean foundBlock = false;
for (int i2 = 0; i2 < mapSize; i2++) {
//Check left
try {
if ((findMoreL) && (pMap[bAX-i2][bAY] <= 3 || pMap[bAX-i2][bAY] == 5|| pMap[bAX-i2][bAY] >= 30)) {
bombs[ID].addMaxLeft(1);
checkItemHit(bAX-i2,bAY);
if (pMap[bAX-i2][bAY] == 5) {
findMoreL = false;
makeItem(bAX-i2,bAY);
foundBlock = true;
}
if ((bAX-i2)%2 == 0 && bAY%2 == 0 && pMap[bAX-i2][bAY] < 30)
pMap[bAX-(i2*tileS)/tileS][bAY] = 0;
else if (pMap[bAX-i2][bAY] < 30)
pMap[bAX-(i2*tileS)/tileS][bAY] = 2;
}
else
findMoreL = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check right
try {
if ((findMoreR) && (pMap[bAX+i2][bAY] <= 3 || pMap[bAX+i2][bAY] == 5 || pMap[bAX+i2][bAY] >= 30)) {
bombs[ID].addMaxRight(1);
checkItemHit(bAX+i2,bAY);
if (pMap[bAX+i2][bAY] == 5) {
findMoreR = false;
makeItem(bAX+i2,bAY);
foundBlock = true;
}
if ((bAX+i2)%2 == 0 && bAY%2 == 0 && pMap[bAX+i2][bAY] < 30)
pMap[bAX+(i2*tileS)/tileS][bAY] = 0;
else if (pMap[bAX+i2][bAY] < 30)
pMap[bAX+(i2*tileS)/tileS][bAY] = 2;
}
else
findMoreR = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check up
try {
if ((findMoreU) && (pMap[bAX][bAY-i2] <= 3 || pMap[bAX][bAY-i2] == 5 || pMap[bAX][bAY-i2] >= 30)) {
bombs[ID].addMaxUp(1);
checkItemHit(bAX,bAY-i2);
if (pMap[bAX][bAY-i2] == 5) {
findMoreU = false;
makeItem(bAX,bAY-i2);
foundBlock = true;
}
if (bAX%2 == 0 && (bAY-i2)%2 == 0 && pMap[bAX][bAY-i2] < 30)
pMap[bAX][bAY-(i2*tileS)/tileS] = 0;
else if (pMap[bAX][bAY-i2] < 30)
pMap[bAX][bAY-(i2*tileS)/tileS] = 2;
}
else
findMoreU = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check down
try {
if ((findMoreD) && (pMap[bAX][bAY+i2] <= 3 || pMap[bAX][bAY+i2] == 5 || pMap[bAX][bAY+i2] >= 30)) {
bombs[ID].addMaxDown(1);
checkItemHit(bAX,bAY+i2);
if (pMap[bAX][bAY+i2] == 5) {
findMoreD = false;
makeItem(bAX,bAY+i2);
foundBlock = true;
}
if (bAX%2 == 0 && (bAY-i2)%2 == 0 && pMap[bAX][bAY+i2] < 30)
pMap[bAX][bAY+(i2*tileS)/tileS] = 0;
else if (pMap[bAX][bAY+i2] < 30)
pMap[bAX][bAY+(i2*tileS)/tileS] = 2;
}
else
findMoreD = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
}
if (foundBlock)
bufferMap();
player[0].setLives(bombs[ID].getMaxLeft());
addExplosion(ID);*/
//}
public void checkDirections(int ID) { //Sets the X's and Y's of the bomb's explosion
bombs[ID].setMaxRight(-1);
bombs[ID].setMaxLeft(-1);
bombs[ID].setMaxUp(-1);
bombs[ID].setMaxDown(-1);
int bAX = bombs[ID].getAbsX();
int bAY = bombs[ID].getAbsY();
boolean findMoreL = true;
boolean findMoreR = true;
boolean findMoreU = true;
boolean findMoreD = true;
boolean foundBlock = false;
int pID = bombs[ID].getPlayerID();
for (int i2 = 0; i2 < mapSize; i2++) {
//Check left
try {
if ((findMoreL) && (player[pID].getExplosionLength() > bombs[ID].getMaxLeft() || isMine[ID]) && (pMap[bAX-i2][bAY] <= 3 || pMap[bAX-i2][bAY] == 5|| pMap[bAX-i2][bAY] >= 30)) {
bombs[ID].addMaxLeft(1);
checkItemHit(bAX-i2,bAY);
if (pMap[bAX-i2][bAY] == 5) {
findMoreL = false;
makeItem(bAX-i2,bAY);
foundBlock = true;
destroyWall(bAX-i2,bAY);
}
}
else
findMoreL = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check right
try {
if ((findMoreR) && (player[pID].getExplosionLength() > bombs[ID].getMaxRight() || isMine[ID]) && (pMap[bAX+i2][bAY] <= 3 || pMap[bAX+i2][bAY] == 5 || pMap[bAX+i2][bAY] >= 30)) {
bombs[ID].addMaxRight(1);
checkItemHit(bAX+i2,bAY);
if (pMap[bAX+i2][bAY] == 5) {
findMoreR = false;
makeItem(bAX+i2,bAY);
foundBlock = true;
destroyWall(bAX+i2,bAY);
}
}
else
findMoreR = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check up
try {
if ((findMoreU) && (player[pID].getExplosionLength() > bombs[ID].getMaxUp() || isMine[ID]) && (pMap[bAX][bAY-i2] <= 3 || pMap[bAX][bAY-i2] == 5 || pMap[bAX][bAY-i2] >= 30)) {
bombs[ID].addMaxUp(1);
checkItemHit(bAX,bAY-i2);
if (pMap[bAX][bAY-i2] == 5) {
findMoreU = false;
makeItem(bAX,bAY-i2);
foundBlock = true;
destroyWall(bAX,bAY-i2);
}
}
else
findMoreU = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
//Check down
try {
if ((findMoreD) && (player[pID].getExplosionLength() > bombs[ID].getMaxDown() || isMine[ID]) && (pMap[bAX][bAY+i2] <= 3 || pMap[bAX][bAY+i2] == 5 || pMap[bAX][bAY+i2] >= 30)) {
bombs[ID].addMaxDown(1);
checkItemHit(bAX,bAY+i2);
if (pMap[bAX][bAY+i2] == 5) {
findMoreD = false;
makeItem(bAX,bAY+i2);
foundBlock = true;
destroyWall(bAX,bAY+i2);
}
}
else
findMoreD = false;
}
catch (ArrayIndexOutOfBoundsException e) { }
}
if (foundBlock)
bufferMap();
}
public void addExplosion(int ID) {
int i;
int aX = bombs[ID].getAbsX();
int aY = bombs[ID].getAbsY();
int X = explosions[ID].toX(aX);
int Y = explosions[ID].toY(aY);
int bC;
b.drawImage(explosion[0],X,Y,tileS,tileS,this);
checkHit(explosions[ID].toAbsX(X), explosions[ID].toAbsY(Y));
for (i = 1; i <= bombs[ID].getMaxRight(); i++) { //Check right
//Draw the correct fire
if (X+i*tileS == bombs[ID].getCenterX() && Y == bombs[ID].getCenterY())
b.drawImage(explosion[0],X+i*tileS,Y,tileS,tileS,this);
else if (i == bombs[ID].getMaxRight())
b.drawImage(explosion[4],(X+i*tileS),(Y),tileS,tileS,this);
else
b.drawImage(explosion[1],(X+i*tileS),(Y),tileS,tileS,this);
//Check if there is another bomb in the line of fire, and make it explode
try {
if (pMap[aX+((i*tileS)/30)][aY]-30 >= 0) {
bC = pMap[aX+((i*tileS)/30)][aY]-30;
explosions[bC] = new Explosion();
explosions[bC].setExplosionTimer((explosionDuration*1000)/cycleTime);
explodeBomb(bC);
bombs[bC].setBomb(false);
bombs[bC].setBombTimer(0);
bombs[bC].setCenter(X+i*tileS, Y);
}
}
catch (ArrayIndexOutOfBoundsException e) { }
checkHit(explosions[ID].toAbsX(X+i*tileS), explosions[ID].toAbsY(Y));
}
for (i = 1; i <= bombs[ID].getMaxLeft(); i++) {
//Draw the correct fire
if (X-i*tileS == bombs[ID].getCenterX() && Y == bombs[ID].getCenterY())
b.drawImage(explosion[0],X-i*tileS,Y,tileS,tileS,this);
else if (i == bombs[ID].getMaxLeft())
b.drawImage(explosion[3],(X-i*tileS),(Y),tileS,tileS,this);
else
b.drawImage(explosion[1],(X-i*tileS),(Y),tileS,tileS,this);
//Check if there is another bomb in the line of fire, and make it explode
try {
if (pMap[aX-(i*tileS)/tileS][aY] >= 30 && i > 0) {
bC = pMap[aX-(i*tileS)/tileS][aY]-30;
if (bC >= 0) {
explosions[bC] = new Explosion();
explosions[bC].setExplosionTimer((explosionDuration*1000)/cycleTime);
explodeBomb(bC);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -