Added Big Explosion, Structed explosion-handling
This commit is contained in:
parent
ec140905ee
commit
1141a53481
BIN
res/images/explosion_proto.png
Normal file
BIN
res/images/explosion_proto.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 187 B |
@ -1,44 +1,53 @@
|
||||
package de.teamteamteam.spacescooter.entity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Explosion extends Entity {
|
||||
import de.teamteamteam.spacescooter.screen.Screen;
|
||||
|
||||
private int count = 71;
|
||||
|
||||
public class Explosion extends LivingEntity {
|
||||
|
||||
private boolean isActive = true;
|
||||
|
||||
public Explosion(int x, int y) {
|
||||
super(x, y);
|
||||
this.setImage("images/explosion1.png");
|
||||
this.setImage("images/explosion_proto.png");
|
||||
this.setPosition(x - (this.getWidth()/2), y - (this.getHeight()/2));
|
||||
Random rand = new Random();
|
||||
if (rand.nextInt(99) <= 70) {
|
||||
Screen.currentScreen.addEntity(new ExplosionOne(x, y));
|
||||
} else {
|
||||
Screen.currentScreen.addEntity(new ExplosionTwo(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
public Explosion(final int x, final int y, final int count, final int height, final int width) {
|
||||
super(x, y);
|
||||
this.setImage("images/explosion_proto.png");
|
||||
this.setPosition(x, y);
|
||||
Thread explosionThread = new Thread(new Runnable() { //not yet compatible
|
||||
public void run() {
|
||||
Random rnd = new Random();
|
||||
for (int i = 0; i <= count; i++) {
|
||||
new Explosion(x + (int) (width*rnd.nextDouble()), y + (int) (height*rnd.nextDouble()));
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (i == count - 1) {
|
||||
isActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
explosionThread.start();
|
||||
if(!this.isActive) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (count >= 0) {
|
||||
count--;
|
||||
} else {
|
||||
this.remove();
|
||||
}
|
||||
switch (count) {
|
||||
case 70:
|
||||
this.setImage("images/explosion1.png");
|
||||
break;
|
||||
case 60:
|
||||
this.setImage("images/explosion2.png");
|
||||
break;
|
||||
case 50:
|
||||
this.setImage("images/explosion3.png");
|
||||
break;
|
||||
case 40:
|
||||
this.setImage("images/explosion4.png");
|
||||
break;
|
||||
case 30:
|
||||
this.setImage("images/explosion5.png");
|
||||
break;
|
||||
case 20:
|
||||
this.setImage("images/explosion6.png");
|
||||
break;
|
||||
case 10:
|
||||
this.setImage("images/explosion7.png");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
43
src/de/teamteamteam/spacescooter/entity/ExplosionOne.java
Normal file
43
src/de/teamteamteam/spacescooter/entity/ExplosionOne.java
Normal file
@ -0,0 +1,43 @@
|
||||
package de.teamteamteam.spacescooter.entity;
|
||||
|
||||
public class ExplosionOne extends LivingEntity {
|
||||
|
||||
private int count = 71;
|
||||
|
||||
public ExplosionOne(int x, int y) {
|
||||
super(x, y);
|
||||
this.setImage("images/explosion_proto.png");
|
||||
this.setPosition(x - (this.getWidth()/2), y - (this.getHeight()/2));
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (count >= 0) {
|
||||
count--;
|
||||
} else {
|
||||
this.remove();
|
||||
}
|
||||
switch (count) {
|
||||
case 70:
|
||||
this.setImage("images/explosion1.png");
|
||||
break;
|
||||
case 60:
|
||||
this.setImage("images/explosion2.png");
|
||||
break;
|
||||
case 50:
|
||||
this.setImage("images/explosion3.png");
|
||||
break;
|
||||
case 40:
|
||||
this.setImage("images/explosion4.png");
|
||||
break;
|
||||
case 30:
|
||||
this.setImage("images/explosion5.png");
|
||||
break;
|
||||
case 20:
|
||||
this.setImage("images/explosion6.png");
|
||||
break;
|
||||
case 10:
|
||||
this.setImage("images/explosion7.png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
71
src/de/teamteamteam/spacescooter/entity/ExplosionTwo.java
Normal file
71
src/de/teamteamteam/spacescooter/entity/ExplosionTwo.java
Normal file
@ -0,0 +1,71 @@
|
||||
package de.teamteamteam.spacescooter.entity;
|
||||
|
||||
public class ExplosionTwo extends LivingEntity {
|
||||
|
||||
private int count = 141;
|
||||
|
||||
public ExplosionTwo(int x, int y) {
|
||||
super(x, y);
|
||||
this.setImage("images/explosion_proto.png");
|
||||
this.setPosition(x - (this.getWidth()/2), y - (this.getHeight()/2));
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (count >= 0) {
|
||||
count--;
|
||||
} else {
|
||||
this.remove();
|
||||
}
|
||||
switch (count) {
|
||||
case 150:
|
||||
this.setImage("images/explosion2_1.png");
|
||||
break;
|
||||
case 140:
|
||||
this.setImage("images/explosion2_2.png");
|
||||
break;
|
||||
case 130:
|
||||
this.setImage("images/explosion2_3.png");
|
||||
break;
|
||||
case 120:
|
||||
this.setImage("images/explosion2_4.png");
|
||||
break;
|
||||
case 110:
|
||||
this.setImage("images/explosion2_5.png");
|
||||
break;
|
||||
case 100:
|
||||
this.setImage("images/explosion2_6.png");
|
||||
break;
|
||||
case 90:
|
||||
this.setImage("images/explosion2_7.png");
|
||||
break;
|
||||
case 80:
|
||||
this.setImage("images/explosion2_8.png");
|
||||
break;
|
||||
case 70:
|
||||
this.setImage("images/explosion2_9.png");
|
||||
break;
|
||||
case 60:
|
||||
this.setImage("images/explosion2_10.png");
|
||||
break;
|
||||
case 50:
|
||||
this.setImage("images/explosion2_11.png");
|
||||
break;
|
||||
case 40:
|
||||
this.setImage("images/explosion2_12.png");
|
||||
break;
|
||||
case 30:
|
||||
this.setImage("images/explosion2_13.png");
|
||||
break;
|
||||
case 20:
|
||||
this.setImage("images/explosion2_14.png");
|
||||
break;
|
||||
case 10:
|
||||
this.setImage("images/explosion2_15.png");
|
||||
break;
|
||||
case 1:
|
||||
this.setImage("images/explosion2_16.png");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,6 @@ package de.teamteamteam.spacescooter.entity;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
|
||||
import de.teamteamteam.spacescooter.screen.Screen;
|
||||
import de.teamteamteam.spacescooter.utility.GameConfig;
|
||||
@ -86,12 +85,7 @@ public abstract class LivingEntity extends Entity implements Collidable {
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
Random rnd = new Random();
|
||||
if (rnd.nextInt(99) < 70) {
|
||||
Screen.currentScreen.addEntity(new Explosion(this.x, this.y));
|
||||
} else {
|
||||
Screen.currentScreen.addEntity(new ExplosionBig(this.x, this.y));
|
||||
}
|
||||
Screen.currentScreen.addEntity(new Explosion(this.x, this.y));
|
||||
}
|
||||
|
||||
public void setHealthPoints(int hp) {
|
||||
|
||||
@ -13,6 +13,7 @@ import de.teamteamteam.spacescooter.entity.EnemyFour;
|
||||
import de.teamteamteam.spacescooter.entity.EnemyThree;
|
||||
import de.teamteamteam.spacescooter.entity.EnemyTwo;
|
||||
import de.teamteamteam.spacescooter.entity.Entity;
|
||||
import de.teamteamteam.spacescooter.entity.Explosion;
|
||||
import de.teamteamteam.spacescooter.entity.Player;
|
||||
|
||||
public class GameScreen extends Screen {
|
||||
@ -31,6 +32,7 @@ public class GameScreen extends Screen {
|
||||
this.entities.add(new EnemyThree(450, 100));
|
||||
this.entities.add(new EnemyTwo(750, 550));
|
||||
this.entities.add(new EnemyTwo(150, 250));
|
||||
this.entities.add(new Explosion(200, 200, 50, 120, 120));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user