diff --git a/res/sounds/shot_hit_something_loud.wav b/res/sounds/shot_hit_something_loud.wav new file mode 100644 index 0000000..3080cef Binary files /dev/null and b/res/sounds/shot_hit_something_loud.wav differ diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java index 56fb1a1..b5ef190 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java @@ -1,16 +1,15 @@ package de.teamteamteam.spacescooter.entity.enemy; -import java.util.Random; import de.teamteamteam.spacescooter.entity.ShootingEntity; import de.teamteamteam.spacescooter.entity.shot.Shot; +import de.teamteamteam.spacescooter.utility.Random; public abstract class Enemy extends ShootingEntity { public Enemy(int x, int y) { super(x, y); - Random r = new Random(); this.name = "EnemyOne"; - this.willShoot = r.nextBoolean(); + this.willShoot = Random.nextBoolean(); this.setShootDirection(Shot.LEFT); this.setShootDamage(5); } diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java index d7f3b0f..5e8702d 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java @@ -1,7 +1,5 @@ package de.teamteamteam.spacescooter.entity.enemy; -import java.util.Random; - import de.teamteamteam.spacescooter.datastructure.ConcurrentIterator; import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.entity.Player; @@ -9,17 +7,16 @@ import de.teamteamteam.spacescooter.entity.explosion.MultiExplosion; import de.teamteamteam.spacescooter.entity.item.Item; import de.teamteamteam.spacescooter.screen.Screen; import de.teamteamteam.spacescooter.utility.GameConfig; +import de.teamteamteam.spacescooter.utility.Random; public class EnemyThree extends Enemy{ private double newY; private double ySpeed = 0.4; - private Random random; private ConcurrentIterator entityIterator; public EnemyThree(int x, int y) { super(x, y); - random = new Random(); this.setImage("images/enemy02.png"); this.setPrimaryShotImage("images/shots/laser_red.png"); this.setShootSpeed(4); @@ -29,7 +26,7 @@ public class EnemyThree extends Enemy{ this.setHealthPoints(15); this.setCollisionDamage(10); this.setScore(30); - this.setPosition(GameConfig.windowWidth, random.nextInt(GameConfig.windowHeight - this.getHeight())); + this.setPosition(GameConfig.windowWidth, Random.nextInt(GameConfig.windowHeight - this.getHeight())); this.newY = this.getY(); this.entityIterator = Screen.currentScreen.createEntityIterator(); } @@ -39,7 +36,7 @@ public class EnemyThree extends Enemy{ */ @Override public void die() { - if(random.nextInt(10) < 5) Item.create(getX(), getY()); + if(Random.nextInt(10) < 5) Item.create(getX(), getY()); new EnemyThree(0, 0); super.die(); } diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java index a21fed7..5882cac 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java @@ -1,14 +1,12 @@ package de.teamteamteam.spacescooter.entity.enemy; -import java.util.Random; - import de.teamteamteam.spacescooter.utility.GameConfig; +import de.teamteamteam.spacescooter.utility.Random; public class EnemyTwo extends Enemy{ public EnemyTwo(int x, int y) { super(x, y); - Random random = new Random(); this.setImage("images/enemy02.png"); this.setPrimaryShotImage("images/shots/laser_green.png"); this.setShootSpeed(4); @@ -19,7 +17,7 @@ public class EnemyTwo extends Enemy{ this.setHealthPoints(5); this.setScore(20); this.setCollisionDamage(this.getHealthPoints()); - this.setPosition(GameConfig.windowWidth, random.nextInt(GameConfig.windowHeight - this.getHeight())); + this.setPosition(GameConfig.windowWidth, Random.nextInt(GameConfig.windowHeight - this.getHeight())); } @Override diff --git a/src/de/teamteamteam/spacescooter/entity/explosion/MultiExplosion.java b/src/de/teamteamteam/spacescooter/entity/explosion/MultiExplosion.java index c6a0e4f..475ced9 100644 --- a/src/de/teamteamteam/spacescooter/entity/explosion/MultiExplosion.java +++ b/src/de/teamteamteam/spacescooter/entity/explosion/MultiExplosion.java @@ -1,6 +1,6 @@ package de.teamteamteam.spacescooter.entity.explosion; -import java.util.Random; +import de.teamteamteam.spacescooter.utility.Random; /** * Extends the functionality of the simple ExplosionOne to randomly @@ -13,17 +13,12 @@ public class MultiExplosion extends ExplosionOne { */ private int counter; - /** - * Instance of Random, so we get good random numbers. - */ - private Random random; - + /** * Just be a single explosion. */ public MultiExplosion(int x, int y) { super(x, y); - this.random = new Random(); } /** @@ -32,7 +27,7 @@ public class MultiExplosion extends ExplosionOne { @Override public void update() { if(this.counter % 10 == 0) { - if(this.random.nextBoolean()) { + if(Random.nextBoolean()) { this.spawnExplosion(); } } @@ -44,11 +39,11 @@ public class MultiExplosion extends ExplosionOne { * Randomly spawn a new random explosion at a random location. */ private void spawnExplosion() { - int x_offset = this.random.nextInt(35); - if(this.random.nextBoolean()) x_offset *= -1; - int y_offset = this.random.nextInt(35); - if(this.random.nextBoolean()) y_offset *= -1; - int explosionType = this.random.nextInt(2); + int x_offset = Random.nextInt(35); + if(Random.nextBoolean()) x_offset *= -1; + int y_offset = Random.nextInt(35); + if(Random.nextBoolean()) y_offset *= -1; + int explosionType = Random.nextInt(2); switch(explosionType) { case 0: new ExplosionOne(this.getX() + x_offset, this.getY() + y_offset); diff --git a/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java b/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java index d21b5e5..ee05e2b 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java +++ b/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java @@ -1,6 +1,6 @@ package de.teamteamteam.spacescooter.entity.item; -import java.util.Random; +import de.teamteamteam.spacescooter.utility.Random; public class ItemChance { @@ -21,8 +21,7 @@ public class ItemChance { public static int choose() { //dauerhaft - Random random = new Random(); - int r = random.nextInt(ItemChance.summe - 1) + 1; + int r = Random.nextInt(ItemChance.summe - 1) + 1; for(int i=0; i