From a16ef5d7a7124d0fb7c835264b7291438f604800 Mon Sep 17 00:00:00 2001 From: lubiana Date: Thu, 6 Nov 2014 18:51:08 +0100 Subject: [PATCH] nullllpointrrrr --- .../spacescooter/entity/ShootingEntity.java | 29 +++++++++---------- .../spacescooter/entity/enemy/Enemy.java | 12 +------- .../spacescooter/entity/shot/Shot.java | 12 ++++---- .../entity/shot/SingleBlueShot.java | 9 ------ .../entity/shot/SingleRedShot.java | 9 ------ .../spacescooter/entity/shot/SingleShot.java | 9 ------ 6 files changed, 21 insertions(+), 59 deletions(-) delete mode 100644 src/de/teamteamteam/spacescooter/entity/shot/SingleBlueShot.java delete mode 100644 src/de/teamteamteam/spacescooter/entity/shot/SingleRedShot.java delete mode 100644 src/de/teamteamteam/spacescooter/entity/shot/SingleShot.java diff --git a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java index 3c9b443..121e80a 100644 --- a/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/ShootingEntity.java @@ -1,6 +1,6 @@ package de.teamteamteam.spacescooter.entity; -import de.teamteamteam.spacescooter.entity.shot.SingleBlueShot; +import de.teamteamteam.spacescooter.entity.shot.Shot; public abstract class ShootingEntity extends LivingEntity { @@ -13,6 +13,7 @@ public abstract class ShootingEntity extends LivingEntity { private int shootDirection; private int damageValue = 5; private int shootSpeed; + private String primaryShotImage = "images/shot01.png"; public ShootingEntity(int x, int y) { super(x, y); @@ -37,7 +38,14 @@ public abstract class ShootingEntity extends LivingEntity { * Override this method in the actual enemy class to change the type of shot the entity creates. */ public void createShot() { - new SingleBlueShot(this.x + this.shootSpawnX, this.y + this.shootSpawnY, this.shootDirection, this.shootSpeed, this.damageValue); + new Shot( + this.x + this.shootSpawnX, + this.y + this.shootSpawnY, + this.shootDirection, + this.shootSpeed, + this.damageValue, + this.primaryShotImage + ); } public void setCanShoot(boolean canShoot) { @@ -76,21 +84,10 @@ public abstract class ShootingEntity extends LivingEntity { public int getDamageValue(){ return this.damageValue; } - - protected int getShootSpawnX(){ - return this.shootSpawnX; + + public void setPrimaryShotImage(String filename){ + this.primaryShotImage = filename; } - protected int getShootSpawnY(){ - return this.shootSpawnY; - } - - protected int getShootDirection(){ - return this.shootDirection; - } - - protected int getShootSpeed(){ - return this.shootSpeed; - } } diff --git a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java index ecb017c..a767401 100644 --- a/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java +++ b/src/de/teamteamteam/spacescooter/entity/enemy/Enemy.java @@ -3,7 +3,6 @@ import java.util.Random; import de.teamteamteam.spacescooter.entity.ShootingEntity; import de.teamteamteam.spacescooter.entity.shot.Shot; -import de.teamteamteam.spacescooter.entity.shot.SingleRedShot; public abstract class Enemy extends ShootingEntity { @@ -13,6 +12,7 @@ public abstract class Enemy extends ShootingEntity { this.name = "EnemyOne"; this.willShoot = r.nextBoolean(); this.setShootDirection(Shot.LEFT); + this.setPrimaryShotImage("images/shot03.png"); } protected String name; @@ -24,16 +24,6 @@ public abstract class Enemy extends ShootingEntity { this.shoot(); } - @Override - public void createShot() { - new SingleRedShot( - super.getX() + super.getShootSpawnX(), - super.getY() + super.getShootSpawnY(), - super.getShootDirection(), - super.getShootSpeed(), - super.getDamageValue() - ); - } } diff --git a/src/de/teamteamteam/spacescooter/entity/shot/Shot.java b/src/de/teamteamteam/spacescooter/entity/shot/Shot.java index f6adc19..b4db16d 100644 --- a/src/de/teamteamteam/spacescooter/entity/shot/Shot.java +++ b/src/de/teamteamteam/spacescooter/entity/shot/Shot.java @@ -3,7 +3,7 @@ package de.teamteamteam.spacescooter.entity.shot; import de.teamteamteam.spacescooter.entity.LivingEntity; import de.teamteamteam.spacescooter.utility.GameConfig; -public abstract class Shot extends LivingEntity { +public class Shot extends LivingEntity { public static final int RIGHT = 1; public static final int LEFT= -1; @@ -14,19 +14,21 @@ public abstract class Shot extends LivingEntity { private int speed; private int direction; - public Shot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { + public Shot(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) { super(x, y); this.direction = shootDirection; this.speed = shootSpeed; this.collisionCount = 1; this.damageValue = damageValue; - } - - public void setImage(String filename) { super.setImage(filename); this.setPosition(this.x - this.getImage().getWidth() / 2, this.y - this.getImage().getHeight() / 2); } + //public void setImage(String filename) { + //super.setImage(filename); + //this.setPosition(this.x - this.getImage().getWidth() / 2, this.y - this.getImage().getHeight() / 2); + //} + public int getDamageValue() { return this.damageValue; } diff --git a/src/de/teamteamteam/spacescooter/entity/shot/SingleBlueShot.java b/src/de/teamteamteam/spacescooter/entity/shot/SingleBlueShot.java deleted file mode 100644 index 6407ff0..0000000 --- a/src/de/teamteamteam/spacescooter/entity/shot/SingleBlueShot.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.teamteamteam.spacescooter.entity.shot; - -public class SingleBlueShot extends Shot { - - public SingleBlueShot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { - super(x, y, shootDirection, shootSpeed, damageValue); - this.setImage("images/shot02.png"); - } -} diff --git a/src/de/teamteamteam/spacescooter/entity/shot/SingleRedShot.java b/src/de/teamteamteam/spacescooter/entity/shot/SingleRedShot.java deleted file mode 100644 index 80f47ea..0000000 --- a/src/de/teamteamteam/spacescooter/entity/shot/SingleRedShot.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.teamteamteam.spacescooter.entity.shot; - -public class SingleRedShot extends Shot { - - public SingleRedShot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { - super(x, y, shootDirection, shootSpeed, damageValue); - this.setImage("images/shot04.png"); - } -} diff --git a/src/de/teamteamteam/spacescooter/entity/shot/SingleShot.java b/src/de/teamteamteam/spacescooter/entity/shot/SingleShot.java deleted file mode 100644 index 87a4e6f..0000000 --- a/src/de/teamteamteam/spacescooter/entity/shot/SingleShot.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.teamteamteam.spacescooter.entity.shot; - -public class SingleShot extends Shot { - - public SingleShot(int x, int y, int shootDirection, int shootSpeed, int damageValue) { - super(x, y, shootDirection, shootSpeed, damageValue); - this.setImage("images/shot02.png"); - } -}