diff --git a/res/images/items/itemBeam.png b/res/images/items/itemBeam.png new file mode 100644 index 0000000..3ee0a78 Binary files /dev/null and b/res/images/items/itemBeam.png differ diff --git a/res/images/shop/select.png b/res/images/shop/select.png new file mode 100644 index 0000000..77f5204 Binary files /dev/null and b/res/images/shop/select.png differ diff --git a/res/images/shop/shopbeam.png b/res/images/shop/shopbeam.png new file mode 100644 index 0000000..82ea31c Binary files /dev/null and b/res/images/shop/shopbeam.png differ diff --git a/res/images/shop/shopbought.png b/res/images/shop/shopbought.png new file mode 100644 index 0000000..a548428 Binary files /dev/null and b/res/images/shop/shopbought.png differ diff --git a/res/images/shop/shopnotbought.png b/res/images/shop/shopnotbought.png new file mode 100644 index 0000000..964d920 Binary files /dev/null and b/res/images/shop/shopnotbought.png differ diff --git a/res/images/shop/shoprocket.png b/res/images/shop/shoprocket.png new file mode 100644 index 0000000..7f7b1df Binary files /dev/null and b/res/images/shop/shoprocket.png differ diff --git a/res/images/shopbackground.png b/res/images/shopbackground.png new file mode 100644 index 0000000..a70ed04 Binary files /dev/null and b/res/images/shopbackground.png differ diff --git a/res/images/shots/beam.png b/res/images/shots/beam.png index 0d78340..e5b9f6e 100644 Binary files a/res/images/shots/beam.png and b/res/images/shots/beam.png differ diff --git a/res/images/shots/beamamount.png b/res/images/shots/beamamount.png new file mode 100644 index 0000000..6f07402 Binary files /dev/null and b/res/images/shots/beamamount.png differ diff --git a/src/de/teamteamteam/spacescooter/brain/PlayerSession.java b/src/de/teamteamteam/spacescooter/brain/PlayerSession.java index 2ce8154..1a704d6 100644 --- a/src/de/teamteamteam/spacescooter/brain/PlayerSession.java +++ b/src/de/teamteamteam/spacescooter/brain/PlayerSession.java @@ -50,6 +50,13 @@ public class PlayerSession { */ private static int shipShotUpgadesBought; + /** + * The secondary weapon of the ship. + * 1 = Rocket. + * 2 = Beam. + */ + private static int secondaryWeapon; + /** * Private constructor, this class will never be instantiated. @@ -216,6 +223,20 @@ public class PlayerSession { PlayerSession.shipShotUpgadesBought++; } + /** + * Get the secondary weapon. + */ + public static int getSecondsecondaryWeapon(){ + return PlayerSession.secondaryWeapon; + } + + /** + * Set the secondary weapon. + */ + public static void setSecondsecondaryWeapon(int secondaryWeapon){ + PlayerSession.secondaryWeapon = secondaryWeapon; + } + /** * This will reset all data from the players session. @@ -225,6 +246,7 @@ public class PlayerSession { */ public static void reset() { PlayerSession.score = 0; + PlayerSession.secondaryWeapon = 1; PlayerSession.credits = 0; PlayerSession.shipHealthPoints = GameConfig.initialPlayerHealthPoints; PlayerSession.shipShieldPoints = GameConfig.initialPlayerShieldPoints; diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index e024d47..c650fcd 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -54,8 +54,8 @@ public class Player extends ShootingEntity implements KeyboardListener { */ public Player(int x, int y) { super(x, y); - this.rocketAmount = 10; - this.beamAmount = 10; + this.rocketAmount = 1; + this.beamAmount = 1; this.collisionCooldown = 150; this.currentCollisionCooldown = 0; this.setImage("images/ship.png"); @@ -112,11 +112,12 @@ public class Player extends ShootingEntity implements KeyboardListener { if(Keyboard.isKeyDown(KeyEvent.VK_SPACE)) { this.shoot(); } - if(Keyboard.isKeyDown(KeyEvent.VK_Y) && this.rocketAmount > 0) { - this.shootRocket(); - } - if(Keyboard.isKeyDown(KeyEvent.VK_X) && this.beamAmount > 0) { - this.shootBeam(); + if(Keyboard.isKeyDown(KeyEvent.VK_Y)) { + if(PlayerSession.getSecondsecondaryWeapon() == 1 && this.rocketAmount > 0) { + this.shootRocket(); + }else if(PlayerSession.getSecondsecondaryWeapon() == 2 && this.beamAmount > 0) { + this.shootBeam(); + } } } diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index e28dcf9..eb5f471 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -261,8 +261,8 @@ public abstract class ShootingEntity extends LivingEntity { */ public void createBeam() { new Beam( - this.getX() + this.shootSpawnX, - this.getY() + this.shootSpawnY, + this.getX() + this.shootSpawnX - 7, + this.getY() + this.shootSpawnY - 3, this.shootDirection, this.shootSpeed, this.shootDamage, diff --git a/src/de/teamteamteam/spacescooter/entity/item/Item.java b/src/de/teamteamteam/spacescooter/entity/item/Item.java index e91f89e..ced3250 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/Item.java +++ b/src/de/teamteamteam/spacescooter/entity/item/Item.java @@ -1,5 +1,6 @@ package de.teamteamteam.spacescooter.entity.item; +import de.teamteamteam.spacescooter.brain.PlayerSession; import de.teamteamteam.spacescooter.entity.CollidableEntity; import de.teamteamteam.spacescooter.entity.Player; import de.teamteamteam.spacescooter.entity.spi.Collidable; @@ -61,7 +62,7 @@ public abstract class Item extends CollidableEntity { items[1] = 4; //ItemCredit items[2] = 2; //ItemHeal items[3] = 2; //ItemShield - items[4] = 2; //ItemRocket + items[4] = 2; //ItemRocket or ItemBeam items[5] = 3; //ItemIncreaseDamage //Add them all up for(i=0; i1){ + this.lifetime++; + if(this.lifetime>1){ + new BeamImage(this.getX(), this.getY()); this.remove(); } } diff --git a/src/de/teamteamteam/spacescooter/entity/shot/BeamImage.java b/src/de/teamteamteam/spacescooter/entity/shot/BeamImage.java new file mode 100644 index 0000000..802600b --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/shot/BeamImage.java @@ -0,0 +1,26 @@ +package de.teamteamteam.spacescooter.entity.shot; + +import de.teamteamteam.spacescooter.entity.Entity; + +public class BeamImage extends Entity { + + private int lifetime = 0; + + + /** + *BeamImage show the image of the beam for a short time, without causing damage. + */ + public BeamImage(int x, int y) { + super(x, y); + this.setImage("images/shots/beam.png"); + } + + @Override + public void update() { + this.lifetime++; + if(this.lifetime>30){ + this.remove(); + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/entity/shot/RocketExplosionRange.java b/src/de/teamteamteam/spacescooter/entity/shot/RocketExplosionRange.java index a491486..785d286 100644 --- a/src/de/teamteamteam/spacescooter/entity/shot/RocketExplosionRange.java +++ b/src/de/teamteamteam/spacescooter/entity/shot/RocketExplosionRange.java @@ -4,7 +4,7 @@ import de.teamteamteam.spacescooter.entity.spi.Collidable; public class RocketExplosionRange extends Shot{ - int i = 0; + int lifetime = 0; public RocketExplosionRange(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) { super(x, y, shootDirection, shootSpeed, damageValue, filename); @@ -14,8 +14,8 @@ public class RocketExplosionRange extends Shot{ * Lifetime of the rocket explosion range. */ public void update() { - i++; - if(i>1){ + lifetime++; + if(lifetime>1){ this.remove(); } } diff --git a/src/de/teamteamteam/spacescooter/gui/ShopOfferValue.java b/src/de/teamteamteam/spacescooter/gui/ImageEntity.java similarity index 53% rename from src/de/teamteamteam/spacescooter/gui/ShopOfferValue.java rename to src/de/teamteamteam/spacescooter/gui/ImageEntity.java index d44c03e..b32422e 100644 --- a/src/de/teamteamteam/spacescooter/gui/ShopOfferValue.java +++ b/src/de/teamteamteam/spacescooter/gui/ImageEntity.java @@ -2,10 +2,12 @@ package de.teamteamteam.spacescooter.gui; import de.teamteamteam.spacescooter.entity.Entity; -//TODO: Create an ImageEntity to do this. -public class ShopOfferValue extends Entity{ +public class ImageEntity extends Entity{ - public ShopOfferValue(int x, int y, String filename) { + /** + * This only show an image. + */ + public ImageEntity(int x, int y, String filename) { super(x, y); setImage(filename); } diff --git a/src/de/teamteamteam/spacescooter/gui/SecondaryWeaponAmount.java b/src/de/teamteamteam/spacescooter/gui/SecondaryWeaponAmount.java new file mode 100644 index 0000000..c6c6c9a --- /dev/null +++ b/src/de/teamteamteam/spacescooter/gui/SecondaryWeaponAmount.java @@ -0,0 +1,36 @@ +package de.teamteamteam.spacescooter.gui; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; + +import de.teamteamteam.spacescooter.brain.PlayerSession; +import de.teamteamteam.spacescooter.entity.Entity; +import de.teamteamteam.spacescooter.screen.GameScreen; + +public class SecondaryWeaponAmount extends Entity{ + + public SecondaryWeaponAmount(int x, int y) { + super(x, y); + if(PlayerSession.getSecondsecondaryWeapon() == 1){ + new ImageEntity(this.getX(), this.getY(), "images/shots/rocket.png"); + }else{ + new ImageEntity(this.getX(), this.getY(), "images/shots/beamamount.png"); + } + } + + @Override + public void paint(Graphics2D g) { + g.setColor(Color.WHITE); + g.setFont(new Font("Monospace", 0, 16)); + if(PlayerSession.getSecondsecondaryWeapon() == 1){ + g.drawString("x " + GameScreen.getPlayer().getRocketAmount(), this.getX() + 30, this.getY() + 12); + }else{ + g.drawString("x " + GameScreen.getPlayer().getBeamAmount(), this.getX() + 30, this.getY() + 12); + } + } + + @Override + public void update() {} + +} diff --git a/src/de/teamteamteam/spacescooter/gui/ShopOffer.java b/src/de/teamteamteam/spacescooter/gui/ShopOffer.java index 9513344..0a02f27 100644 --- a/src/de/teamteamteam/spacescooter/gui/ShopOffer.java +++ b/src/de/teamteamteam/spacescooter/gui/ShopOffer.java @@ -19,9 +19,9 @@ public class ShopOffer extends Entity { this.max = max; for (int i = 0; i0) { this.menuPoint--; - this.player.setPosition(50, this.player.getY()); - this.player.setPosition(this.player.getX(), 159+(this.menuPoint*100)); + if(menuPoint == 3){ + this.player.setPosition(GameConfig.windowWidth/2-180, 390); + }else{ + this.player.setPosition(50, 149+(this.menuPoint*75)); + } } + + /** + * Selection. + */ }else if ( (Keyboard.isKeyDown(KeyEvent.VK_SPACE) || Keyboard.isKeyDown(KeyEvent.VK_ENTER)) && !this.keyPressed && this.animationStatus == 0) { this.keyPressed = true; - /////////////////////////////////////////////////////////////// switch (this.menuPoint) { case 0: if(PlayerSession.getCredits() >= 5 && damage.getBought() < damage.getMax()){ @@ -99,6 +128,15 @@ public class ShopScreen extends Screen { } break; case 3: + if(PlayerSession.getSecondsecondaryWeapon() == 1){ + select.setPosition(GameConfig.windowWidth / 2 + 20, 355); + PlayerSession.setSecondsecondaryWeapon(2); + }else{ + select.setPosition(GameConfig.windowWidth / 2 - 130, 355); + PlayerSession.setSecondsecondaryWeapon(1); + } + break; + case 4: this.animationStatus = 1; break; } @@ -107,6 +145,9 @@ public class ShopScreen extends Screen { this.keyPressed = false; } + /** + * Animation. + */ if(this.animationStatus == 1) { if(this.player.getX() <= GameConfig.windowWidth) { this.player.setPosition(this.player.getX() + (int) playerMoveSpeed, this.player.getY());