diff --git a/res/images/items/itemRocket.png b/res/images/items/itemRocket.png new file mode 100644 index 0000000..6b58da4 Binary files /dev/null and b/res/images/items/itemRocket.png differ diff --git a/res/images/shots/rocket.png b/res/images/shots/rocket.png new file mode 100644 index 0000000..dd5d2af Binary files /dev/null and b/res/images/shots/rocket.png differ diff --git a/res/images/shots/rocket_explosion.png b/res/images/shots/rocket_explosion.png new file mode 100644 index 0000000..8ea1362 Binary files /dev/null and b/res/images/shots/rocket_explosion.png differ diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index a2a1f30..440ec6e 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -15,6 +15,7 @@ public class Player extends ShootingEntity implements KeyboardListener { private Keyboard keyboard = null; private double healthPercent = 0; private double shieldPercent = 0; + private int rocketAmount = 1; public Player(int x, int y) { super(x, y); @@ -62,6 +63,11 @@ public class Player extends ShootingEntity implements KeyboardListener { if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) { this.shoot(); } + if(Keyboard.isKeyDown(KeyEvent.VK_Y)) { + if(rocketAmount > 0){ + this.shootRocket(); + } + } } } @@ -133,4 +139,25 @@ public class Player extends ShootingEntity implements KeyboardListener { } } + /** + * Get the current rocket amount. + */ + public int getRocketAmount(){ + return rocketAmount; + } + + /** + * Add one rocket. + */ + public void addRocketAmount(){ + rocketAmount++; + } + + /** + * Remove one rocket. + */ + public void removeRocketAmount(){ + rocketAmount--; + } + } diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index 95ea24a..710e733 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -1,6 +1,8 @@ package de.teamteamteam.spacescooter.entity; +import de.teamteamteam.spacescooter.entity.shot.Rocket; import de.teamteamteam.spacescooter.entity.shot.Shot; +import de.teamteamteam.spacescooter.screen.GameScreen; /** * The ShootingEntity is a LivingEntity that is able to fire Shots. @@ -26,6 +28,12 @@ public abstract class ShootingEntity extends LivingEntity { */ private int currentShootDelay; + /** + * The current tick delay to wait until the next Rocket can be fired. + * This value is used to enforce the actual delay defined in shootDelay. + */ + private int currentRocketDelay; + /** * The X delta to pass to the Shot, so it spawns at the * right position relative to the ShootingEntity. @@ -74,6 +82,7 @@ public abstract class ShootingEntity extends LivingEntity { */ public void update() { if(this.currentShootDelay > 0) this.currentShootDelay--; + if(this.currentRocketDelay > 0) this.currentRocketDelay--; } /** @@ -88,6 +97,16 @@ public abstract class ShootingEntity extends LivingEntity { } } } + + public void shootRocket() { + if(this.canShoot == true) { + if(this.currentRocketDelay == 0) { + this.createRocket(); + GameScreen.getPlayer().removeRocketAmount(); + this.currentRocketDelay = this.shootDelay*3; + } + } + } /** * Enable or disable the ShootingEntitys fire ability. @@ -177,6 +196,17 @@ public abstract class ShootingEntity extends LivingEntity { ); } + public void createRocket() { + new Rocket( + this.getX() + this.shootSpawnX, + this.getY() + this.shootSpawnY, + this.shootDirection, + this.shootSpeed, + (int)(this.shootDamage*1.5), + this.primaryShotImage + ); + } + /** * Custom Shoot for Custom Action!!! */ @@ -190,4 +220,5 @@ public abstract class ShootingEntity extends LivingEntity { filename ); } + } diff --git a/src/de/teamteamteam/spacescooter/entity/item/Item.java b/src/de/teamteamteam/spacescooter/entity/item/Item.java index b85ecba..e0ec96c 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/Item.java +++ b/src/de/teamteamteam/spacescooter/entity/item/Item.java @@ -30,8 +30,17 @@ public abstract class Item extends CollidableEntity { }; } + /** + * Item property. + * What happens when item is collected. + */ public abstract void itemCollected(Player player); + /** + * Selects which item spawns. + * + * (If you add a new item, you must also add it in ItemChance.java) + */ public static void create(int x, int y){ int auswahl = ItemChance.choose(); switch (auswahl) { @@ -48,7 +57,7 @@ public abstract class Item extends CollidableEntity { new ItemShield(x, y); break; case 4: - new TestItem1(x, y); + new ItemRocket(x, y); break; } } diff --git a/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java b/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java index ee05e2b..161b605 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java +++ b/src/de/teamteamteam/spacescooter/entity/item/ItemChance.java @@ -7,12 +7,21 @@ public class ItemChance { private static int summe = 0; private static int[] items; + /** + * Item spawn probability, + * higher number, higher spawn rate, + * same number, same spawn rate. + * + * New items must be registered here!! + */ public ItemChance() { - ItemChance.items = new int[4]; - items[0] = 4; - items[1] = 3; - items[2] = 2; - items[3] = 1; + ItemChance.items = new int[6]; + items[0] = 1; //ItemNuke + items[2] = 2; //ItemHeal + items[3] = 2; //ItemShield + items[4] = 2; //ItemRocket + items[1] = 4; //ItemCredit + items[5] = 3; //ItemIncreaseDamage for(int i=0; i10){ + this.remove(); + } + } + + @Override + public void collideWith(Collidable entity) { + } +} diff --git a/src/de/teamteamteam/spacescooter/entity/shot/Shot.java b/src/de/teamteamteam/spacescooter/entity/shot/Shot.java index 90c7d7e..92170b4 100644 --- a/src/de/teamteamteam/spacescooter/entity/shot/Shot.java +++ b/src/de/teamteamteam/spacescooter/entity/shot/Shot.java @@ -76,6 +76,13 @@ public class Shot extends CollidableEntity { this.damageValue = dmg; } + /** + * Returns the shot speed. + */ + public int getSpeed(){ + return speed; + } + /** * Make the shot travel in the right direction. * Remove the shot once out of the visible area. diff --git a/src/de/teamteamteam/spacescooter/gui/Credits.java b/src/de/teamteamteam/spacescooter/gui/Credits.java index 92bd006..1d80899 100644 --- a/src/de/teamteamteam/spacescooter/gui/Credits.java +++ b/src/de/teamteamteam/spacescooter/gui/Credits.java @@ -8,7 +8,7 @@ public class Credits { /** * Credit points for the shop */ - private static int credits = 1000; + private static int credits = 0; /** diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index 4826f30..899db25 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -26,6 +26,9 @@ import de.teamteamteam.spacescooter.utility.CollisionHandler; */ public class GameScreen extends Screen { + /** + * Road points for EnemyFour + */ private ArrayList points = new ArrayList(); private static Player player;