diff --git a/res/images/shots/beam.png b/res/images/shots/beam.png new file mode 100644 index 0000000..0d78340 Binary files /dev/null and b/res/images/shots/beam.png differ diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index c8e1912..54277da 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -33,7 +33,12 @@ public class Player extends ShootingEntity implements KeyboardListener { /** * the Players Rocket Ammunition */ - private int rocketAmount = 1; + private int rocketAmount = 10; + + /** + * the Players Beam Ammunition + */ + private int beamAmount = 10; /** @@ -96,6 +101,11 @@ public class Player extends ShootingEntity implements KeyboardListener { this.shootRocket(); } } + if(Keyboard.isKeyDown(KeyEvent.VK_X)) { + if(this.beamAmount > 0){ + this.shootBeam(); + } + } } } @@ -209,6 +219,10 @@ public class Player extends ShootingEntity implements KeyboardListener { return rocketAmount; } + public int getBeamAmount(){ + return beamAmount; + } + /** * Add one rocket. */ @@ -216,6 +230,10 @@ public class Player extends ShootingEntity implements KeyboardListener { rocketAmount++; } + public void addBeamAmount(){ + beamAmount++; + } + /** * Remove one rocket. */ @@ -223,4 +241,8 @@ public class Player extends ShootingEntity implements KeyboardListener { rocketAmount--; } + public void removeBeamAmount(){ + beamAmount--; + } + } diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index 710e733..7d6dfea 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -1,5 +1,6 @@ package de.teamteamteam.spacescooter.entity; +import de.teamteamteam.spacescooter.entity.shot.Beam; import de.teamteamteam.spacescooter.entity.shot.Rocket; import de.teamteamteam.spacescooter.entity.shot.Shot; import de.teamteamteam.spacescooter.screen.GameScreen; @@ -34,6 +35,8 @@ public abstract class ShootingEntity extends LivingEntity { */ private int currentRocketDelay; + private int currentBeamDelay; + /** * The X delta to pass to the Shot, so it spawns at the * right position relative to the ShootingEntity. @@ -83,6 +86,7 @@ public abstract class ShootingEntity extends LivingEntity { public void update() { if(this.currentShootDelay > 0) this.currentShootDelay--; if(this.currentRocketDelay > 0) this.currentRocketDelay--; + if(this.currentBeamDelay > 0) this.currentBeamDelay--; } /** @@ -108,6 +112,15 @@ public abstract class ShootingEntity extends LivingEntity { } } + public void shootBeam() { + if(this.canShoot == true) { + if(this.currentBeamDelay == 0) { + this.createBeam(); + GameScreen.getPlayer().removeBeamAmount(); + this.currentBeamDelay = this.shootDelay; + } + } + } /** * Enable or disable the ShootingEntitys fire ability. */ @@ -220,5 +233,15 @@ public abstract class ShootingEntity extends LivingEntity { filename ); } + public void createBeam() { + new Beam( + this.getX() + this.shootSpawnX, + this.getY() + this.shootSpawnY, + this.shootDirection, + this.shootSpeed, + this.shootDamage, + this.primaryShotImage + ); + } } diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java index a13e7b2..b710091 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java @@ -37,8 +37,12 @@ public abstract class Enemy extends ShootingEntity { */ public void update() { super.update(); - if(willShoot == true) + if(willShoot == true){ this.shoot(); + } + if(this.getX() < 0-getWidth()){ + this.remove(); + } } @Override diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java index 4a538d4..ca387c6 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyThree.java @@ -49,10 +49,6 @@ public class EnemyThree extends Enemy{ public void update() { super.update(); this.setPosition(this.getX()-1, this.getY()); - if(this.getX() < 0-getWidth()){ - this.remove(); - new EnemyThree(0, 0); - } Player player = GameScreen.getPlayer(); if(this.getY() < player.getY()){ this.newY += ySpeed; diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java index 5882cac..a2adec3 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/EnemyTwo.java @@ -24,10 +24,6 @@ public class EnemyTwo extends Enemy{ public void update() { super.update(); this.setPosition(this.getX()-1, this.getY()); - if(this.getX() < 0-getWidth()){ - this.remove(); - new EnemyTwo(0, 0); - } if(!this.isAlive()){ new EnemyTwo(0, 0); } diff --git a/src/de/teamteamteam/spacescooter/entity/shot/Beam.java b/src/de/teamteamteam/spacescooter/entity/shot/Beam.java new file mode 100644 index 0000000..226bd1e --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/shot/Beam.java @@ -0,0 +1,19 @@ +package de.teamteamteam.spacescooter.entity.shot; + +public class Beam extends Shot{ + + int i =0; + + public Beam(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) { + super(x, y-35, shootDirection, shootSpeed, damageValue, filename); + this.setImage("images/shots/beam.png"); + } + + @Override + public void update() { + i++; + if(i>100){ + this.remove(); + } + } +}