Merge branch 'master' of github.com:teamteamteam/SpaceScooter

This commit is contained in:
lubiana 2014-11-04 14:06:07 +01:00
commit c2de2567d2
6 changed files with 89 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

View File

@ -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;
}
}
}

View 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;
}
}
}

View File

@ -1,11 +1,13 @@
package de.teamteamteam.spacescooter.entity;
public class ExplosionBig extends Explosion {
public class ExplosionTwo extends LivingEntity {
private int count = 141;
public ExplosionBig(int x, int y) {
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() {

View File

@ -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;
@ -91,12 +90,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) {

View File

@ -12,6 +12,7 @@ import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.EnemyFour;
import de.teamteamteam.spacescooter.entity.EnemyThree;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.Explosion;
import de.teamteamteam.spacescooter.entity.ItemChance;
import de.teamteamteam.spacescooter.entity.Player;