diff --git a/res/images/Item.png b/res/images/Item.png new file mode 100644 index 0000000..799d50f Binary files /dev/null and b/res/images/Item.png differ diff --git a/res/images/Item2.png b/res/images/Item2.png new file mode 100644 index 0000000..c1bae5b Binary files /dev/null and b/res/images/Item2.png differ diff --git a/res/images/Item3.png b/res/images/Item3.png new file mode 100644 index 0000000..9c1c635 Binary files /dev/null and b/res/images/Item3.png differ diff --git a/res/images/Item4.png b/res/images/Item4.png new file mode 100644 index 0000000..fd349ea Binary files /dev/null and b/res/images/Item4.png differ diff --git a/res/images/shot02.png b/res/images/shot02.png new file mode 100644 index 0000000..5a9cf1a Binary files /dev/null and b/res/images/shot02.png differ diff --git a/res/images/shot03.png b/res/images/shot03.png new file mode 100644 index 0000000..ed53a3c Binary files /dev/null and b/res/images/shot03.png differ diff --git a/res/images/shot04.png b/res/images/shot04.png new file mode 100644 index 0000000..f06ba7e Binary files /dev/null and b/res/images/shot04.png differ diff --git a/res/images/shot05.png b/res/images/shot05.png new file mode 100644 index 0000000..48f6df2 Binary files /dev/null and b/res/images/shot05.png differ diff --git a/src/de/teamteamteam/spacescooter/entity/EnemyFour.java b/src/de/teamteamteam/spacescooter/entity/EnemyFour.java index efddfde..03a8221 100644 --- a/src/de/teamteamteam/spacescooter/entity/EnemyFour.java +++ b/src/de/teamteamteam/spacescooter/entity/EnemyFour.java @@ -52,9 +52,7 @@ public class EnemyFour extends Enemy{ nextPoint = points.get(index); index++; neuerVektor(); - System.out.println("neuer point"); }catch(IndexOutOfBoundsException e){ - System.out.println("ich bin dann mal weg!!"); this.remove(); } } diff --git a/src/de/teamteamteam/spacescooter/entity/EnemyThree.java b/src/de/teamteamteam/spacescooter/entity/EnemyThree.java index 95fd918..272b09c 100644 --- a/src/de/teamteamteam/spacescooter/entity/EnemyThree.java +++ b/src/de/teamteamteam/spacescooter/entity/EnemyThree.java @@ -11,15 +11,16 @@ public class EnemyThree extends Enemy{ private double newY; private double ySpeed = 0.4; + private Random random; public EnemyThree(int x, int y) { super(x, y); - Random random = new Random(); + random = new Random(); this.setImage("images/nyancat.png"); this.setShootSpeed(4); this.setShootDelay(42); this.setShootSpawn(-10, 10); - this.setHealthPoints(5); + this.setHealthPoints(15); this.setPosition(GameConfig.windowWidth, random.nextInt(GameConfig.windowHeight - this.getHeight())); this.newY = this.getY(); } @@ -33,6 +34,7 @@ public class EnemyThree extends Enemy{ Screen.currentScreen.addEntity(new EnemyThree(0, 0)); } if(!this.isAlive()){ + if(random.nextInt(10) < 5) Items.create(getX(), getY()); Screen.currentScreen.addEntity(new EnemyThree(0, 0)); } LinkedList list = Screen.currentScreen.getEntities(); diff --git a/src/de/teamteamteam/spacescooter/entity/ExplosionBig.java b/src/de/teamteamteam/spacescooter/entity/ExplosionBig.java deleted file mode 100644 index eb6f8cf..0000000 --- a/src/de/teamteamteam/spacescooter/entity/ExplosionBig.java +++ /dev/null @@ -1,69 +0,0 @@ -package de.teamteamteam.spacescooter.entity; - -public class ExplosionBig extends Explosion { - - private int count = 141; - - public ExplosionBig(int x, int y) { - super(x, y); - } - - 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; - } - } - -} diff --git a/src/de/teamteamteam/spacescooter/entity/ItemChance.java b/src/de/teamteamteam/spacescooter/entity/ItemChance.java new file mode 100644 index 0000000..72a420a --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/ItemChance.java @@ -0,0 +1,35 @@ +package de.teamteamteam.spacescooter.entity; + +import java.util.Random; + +public class ItemChance { + + private static int summe = 0; + private static int[] items; + + public ItemChance() { + ItemChance.items = new int[4]; + items[0] = 4; + items[1] = 3; + items[2] = 2; + items[3] = 1; + + for(int i=0; i entities = Screen.currentScreen.getEntities(); + for (Entity e : entities) { + if(e instanceof Player){ + itemCollected((Player) e); + } + } + } + } + + public abstract void itemCollected(Player player); + + public static void create(int x, int y){ + int auswahl = ItemChance.choose(); + switch (auswahl) { + case 0: + Screen.currentScreen.addEntity(new TestItem1(x, y)); + break; + case 1: + Screen.currentScreen.addEntity(new TestItem2(x, y)); + break; + case 2: + Screen.currentScreen.addEntity(new TestItem3(x, y)); + break; + case 3: + Screen.currentScreen.addEntity(new TestItem4(x, y));; + break; + } + } +} diff --git a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java index 17244a9..7c8b9c8 100644 --- a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java @@ -54,6 +54,11 @@ public abstract class LivingEntity extends Entity implements Collidable { enemy.takeDamage(this.getCollisionDamage()); this.takeDamage(enemy.getCollisionDamage()); } + if(this instanceof Player && entity instanceof Items){ + Items item = (Items) entity; + item.setHealthPoints(0); + item.remove(); + } } public void setCollisionDamage(int d) { diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 796221a..b6e2004 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -9,13 +9,14 @@ public class Player extends ShootingEntity { protected boolean shoot = false; private boolean canMove = true; + public Player(int x, int y) { super(x, y); this.setImage("images/ship.png"); this.setShootDelay(5); this.setShootSpawn(50, 16); this.setShootDirection(Shot.RIGHT); - this.setShootSpeed(4); + this.setShootSpeed(10); this.setHealthPoints(100); } diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index b1b6bac..0835c94 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -9,6 +9,7 @@ public abstract class ShootingEntity extends LivingEntity { private int shootSpawnX; private int shootSpawnY; private int shootDirection; + private int damageValue = 5; private int shootSpeed; public ShootingEntity(int x, int y) { @@ -23,7 +24,7 @@ public abstract class ShootingEntity extends LivingEntity { protected void shoot() { if(this.currentShootDelay == 0) { - Screen.currentScreen.addEntity(new SingleShot(this.x + this.shootSpawnX, this.y + this.shootSpawnY, this.shootDirection, this.shootSpeed)); + Screen.currentScreen.addEntity(new SingleShot(this.x + this.shootSpawnX, this.y + this.shootSpawnY, this.shootDirection, this.shootSpeed, this.damageValue)); this.currentShootDelay = this.shootDelay; } } @@ -44,4 +45,12 @@ public abstract class ShootingEntity extends LivingEntity { this.shootSpawnX = x; this.shootSpawnY = y; } + + public void setDamageValue(int damageValue){ + this.damageValue = damageValue; + } + + public int getDamageValue(){ + return this.damageValue; + } } diff --git a/src/de/teamteamteam/spacescooter/entity/Shot.java b/src/de/teamteamteam/spacescooter/entity/Shot.java index 48c6f19..fe4eec0 100644 --- a/src/de/teamteamteam/spacescooter/entity/Shot.java +++ b/src/de/teamteamteam/spacescooter/entity/Shot.java @@ -13,11 +13,12 @@ public abstract class Shot extends LivingEntity { private int speed; private int direction; - public Shot(int x, int y, int shootDirection, int shootSpeed) { + public Shot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { super(x, y); this.direction = shootDirection; this.speed = shootSpeed; this.collisionCount = 1; + this.damageValue = damageValue; } public void setImage(String filename) { diff --git a/src/de/teamteamteam/spacescooter/entity/SingleShot.java b/src/de/teamteamteam/spacescooter/entity/SingleShot.java index 182e6a3..3850ba8 100644 --- a/src/de/teamteamteam/spacescooter/entity/SingleShot.java +++ b/src/de/teamteamteam/spacescooter/entity/SingleShot.java @@ -2,10 +2,8 @@ package de.teamteamteam.spacescooter.entity; public class SingleShot extends Shot { - public SingleShot(int x, int y, int shootDirection, int shootSpeed) { - super(x, y, shootDirection, shootSpeed); + public SingleShot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { + super(x, y, shootDirection, shootSpeed, damageValue); this.setImage("images/shot.png"); - this.setDamageValue(5); } - } diff --git a/src/de/teamteamteam/spacescooter/entity/TestItem1.java b/src/de/teamteamteam/spacescooter/entity/TestItem1.java new file mode 100644 index 0000000..251f970 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/TestItem1.java @@ -0,0 +1,14 @@ +package de.teamteamteam.spacescooter.entity; + +public class TestItem1 extends Items{ + + public TestItem1(int x, int y) { + super(x, y); + this.setImage("images/Item.png"); + } + + @Override + public void itemCollected(Player player) { + player.setDamageValue(player.getDamageValue()+5); + } +} diff --git a/src/de/teamteamteam/spacescooter/entity/TestItem2.java b/src/de/teamteamteam/spacescooter/entity/TestItem2.java new file mode 100644 index 0000000..3be7f51 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/TestItem2.java @@ -0,0 +1,16 @@ +package de.teamteamteam.spacescooter.entity; + +public class TestItem2 extends Items{ + + public static int chance = 2; + + public TestItem2(int x, int y) { + super(x, y); + this.setImage("images/Item2.png"); + } + + @Override + public void itemCollected(Player player) { + player.setDamageValue(player.getDamageValue()+5); + } +} diff --git a/src/de/teamteamteam/spacescooter/entity/TestItem3.java b/src/de/teamteamteam/spacescooter/entity/TestItem3.java new file mode 100644 index 0000000..658d70d --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/TestItem3.java @@ -0,0 +1,16 @@ +package de.teamteamteam.spacescooter.entity; + +public class TestItem3 extends Items{ + + public static int chance = 3; + + public TestItem3(int x, int y) { + super(x, y); + this.setImage("images/Item3.png"); + } + + @Override + public void itemCollected(Player player) { + player.setDamageValue(player.getDamageValue()+5); + } +} diff --git a/src/de/teamteamteam/spacescooter/entity/TestItem4.java b/src/de/teamteamteam/spacescooter/entity/TestItem4.java new file mode 100644 index 0000000..69f8e21 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/TestItem4.java @@ -0,0 +1,16 @@ +package de.teamteamteam.spacescooter.entity; + +public class TestItem4 extends Items{ + + public static int chance = 4; + + public TestItem4(int x, int y) { + super(x, y); + this.setImage("images/Item4.png"); + } + + @Override + public void itemCollected(Player player) { + player.setDamageValue(player.getDamageValue()+5); + } +} diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 1b712c6..051d0cf 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -11,9 +11,9 @@ import de.teamteamteam.spacescooter.background.StarBackground; import de.teamteamteam.spacescooter.control.Keyboard; 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.ItemChance; import de.teamteamteam.spacescooter.entity.Player; public class GameScreen extends Screen { @@ -22,6 +22,7 @@ public class GameScreen extends Screen { public GameScreen(Screen parent) { super(parent); + new ItemChance(); points.add(new Point(300,300)); points.add(new Point(600,100)); points.add(new Point(0,500)); @@ -30,9 +31,6 @@ public class GameScreen extends Screen { this.entities.add(new EnemyFour(800, 400, points)); this.entities.add(new EnemyThree(650, 300)); 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