From 7437a5c18df2a6e96bf109c2a1086df4b51acbea Mon Sep 17 00:00:00 2001 From: Sosch Date: Mon, 24 Nov 2014 23:33:56 +0100 Subject: [PATCH] Add rocket (fire button: y), add ItemRocket (increase rocket amount), add some comments --- res/images/items/itemRocket.png | Bin 0 -> 1171 bytes res/images/shots/rocket.png | Bin 0 -> 307 bytes res/images/shots/rocket_explosion.png | Bin 0 -> 373 bytes .../spacescooter/entity/Player.java | 27 +++++++++++++++ .../spacescooter/entity/ShootingEntity.java | 31 ++++++++++++++++++ .../spacescooter/entity/item/Item.java | 11 ++++++- .../spacescooter/entity/item/ItemChance.java | 20 +++++++---- .../spacescooter/entity/item/ItemCredit.java | 5 ++- .../spacescooter/entity/item/ItemHeal.java | 2 -- ...TestItem1.java => ItemIncreaseDamage.java} | 5 +-- .../spacescooter/entity/item/ItemNuke.java | 2 -- .../spacescooter/entity/item/ItemOneUp.java | 4 +-- .../spacescooter/entity/item/ItemRocket.java | 17 ++++++++++ .../spacescooter/entity/item/ItemShield.java | 2 -- .../spacescooter/entity/shot/Rocket.java | 20 +++++++++++ .../entity/shot/RocketExplosionRange.java | 26 +++++++++++++++ .../spacescooter/entity/shot/Shot.java | 7 ++++ .../spacescooter/gui/Credits.java | 2 +- .../spacescooter/screen/GameScreen.java | 3 ++ 19 files changed, 162 insertions(+), 22 deletions(-) create mode 100644 res/images/items/itemRocket.png create mode 100644 res/images/shots/rocket.png create mode 100644 res/images/shots/rocket_explosion.png rename src/de/teamteamteam/spacescooter/entity/item/{TestItem1.java => ItemIncreaseDamage.java} (71%) create mode 100644 src/de/teamteamteam/spacescooter/entity/item/ItemRocket.java create mode 100644 src/de/teamteamteam/spacescooter/entity/shot/Rocket.java create mode 100644 src/de/teamteamteam/spacescooter/entity/shot/RocketExplosionRange.java diff --git a/res/images/items/itemRocket.png b/res/images/items/itemRocket.png new file mode 100644 index 0000000000000000000000000000000000000000..6b58da4a215467c95fe4bb8e68cc77eea62c3e11 GIT binary patch literal 1171 zcmV;E1Z?|>P)nY zNXB*hL5BkH!rt=%hP5~CO{=%Ju{ARTfk})s8;H$XIJ0{u+=B?mJ@5#kodkiWU-$l6 zK!g(x9>G$)83zJzdgs{)Z-qJGSx^z?K{)A`=+^T$?g4lP!%Pqp0G`=C72XOh!omsC zVVyQS&#bAs<{3l+=;0Z}QascLPX2x})H<0NNJwDS-c}t>Q|vB)DSNC$ij0v)n$W<) z?S)S5t!=%ivAMN-^^NkLh-R-t^!>)mvwKeygYqZBK}H0aLkL2`L_Q4608e^z2eagG zbgvPC9NZkk2m)bg#RHeHh`tHte?1W;eobk!S&3_L;lm44J^02KKh*?OO=ALV%rtG- zlJ?|0F#zxY;ou?^$g;C#gx@}RFd=+pION>>uRSt}ZGE#vcj0uRJ4oJX;Hh7p44GkA z&UPu2ZNK|!J?PlQE4_pN{qAkPymaZI!q?W;>i=7pZ}n2P%-9&L%Z_gzj}mH5a;`t# zJ6DAtyLhD&{!yO$9LvkgReNXOIh!50gtl}3zw=>UGgkt!`@!pn7Cb&W5R1KRNd$wS zJiy-S8+~;jLg+LQE5l(5RWl67Lkz+lHzoT&CgJS}K+%P-6;%XLoeO}E9}|F_nv=f; z7M`n}JM*7@KMCT9fUFFMIS@->OEN9_K$k90eAa6c(A@R8Fj*xP zG<56U>RU&a2X1`zGos6iCCdt6us#=+-PG!3IcdP%)uoxYdeqqX{Kr}eQ;MfDshh)_ zDHVqYVNNQhR&6CuNM{MV`pMOt)ykpPE4@fq2uCPVEr?KZK5L4RjTFipE~%;GdXn{2 z*S&8v)nmx1;K*!}Gg#T5*0<)jREdE`7Sot+wO9FAWam+a}Z?=$ckNm(nq&;6-` z_lDPqUQ%j+6m3{952zQuM*3#&#k)FGbE=U=0bq?L$bEo~g>4D7`-}Gv*PKopbL)es lwk|$E*OdJI%0CA>^MA%Go8^8bn002ovPDHLkV1mhN6FdL_ literal 0 HcmV?d00001 diff --git a/res/images/shots/rocket.png b/res/images/shots/rocket.png new file mode 100644 index 0000000000000000000000000000000000000000..dd5d2af51d6f145ad293326b3c247901fa3c6715 GIT binary patch literal 307 zcmeAS@N?(olHy`uVBq!ia0vp^k{~t*8<31yck~^Q;wbCYGe8D3oWGWGJ|M`UZqI@`(c# zt@U(q46!)9cZ#7T(Mwi)ot6e;!_* z|9@G<8d(J|nwXzI!&IMDc=+%Prc0T7PkyoPh%nBNn!nceJ=^wu@vIilxn}sBRbG(! zm)&5`akt29!?p>sJH0NapJab?NrK60t)t6iEe7ke&mBH#IA}@gi!c<}auj`x6ItN3 y;l~qIh9wK4HgF`Q6?)B|bLr!&@SUdr)`>g6486sXqf`!bID@CFpUXO@geCxsYHBwC literal 0 HcmV?d00001 diff --git a/res/images/shots/rocket_explosion.png b/res/images/shots/rocket_explosion.png new file mode 100644 index 0000000000000000000000000000000000000000..8ea1362a601ff9199de6f3d2c538d70f4fc44552 GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp^(?FPm2}o{Eezp}zaTa()7Bet#3xhBt!>lbCYGe8D3oWGWGJ|M`UZqI@`(c# zz4vr+45_&F_97!M0|Uolg9H1YD>qLl5xVC0vOJm5Nm0b9#Yv;ZsUv`+HGo5qYoP#_ zB1llt1t_S|0upQ$017S?Pyz}L62&;(wqmxJffbW>^ShdpK(8}+y85}Sb4q9e0Hilz AXaE2J literal 0 HcmV?d00001 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;