nullllpointrrrr

This commit is contained in:
lubiana 2014-11-06 18:51:08 +01:00
parent 6f2857946d
commit a16ef5d7a7
6 changed files with 21 additions and 59 deletions

View File

@ -1,6 +1,6 @@
package de.teamteamteam.spacescooter.entity; 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 { public abstract class ShootingEntity extends LivingEntity {
@ -13,6 +13,7 @@ public abstract class ShootingEntity extends LivingEntity {
private int shootDirection; private int shootDirection;
private int damageValue = 5; private int damageValue = 5;
private int shootSpeed; private int shootSpeed;
private String primaryShotImage = "images/shot01.png";
public ShootingEntity(int x, int y) { public ShootingEntity(int x, int y) {
super(x, 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. * Override this method in the actual enemy class to change the type of shot the entity creates.
*/ */
public void createShot() { 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) { public void setCanShoot(boolean canShoot) {
@ -77,20 +85,9 @@ public abstract class ShootingEntity extends LivingEntity {
return this.damageValue; return this.damageValue;
} }
protected int getShootSpawnX(){ public void setPrimaryShotImage(String filename){
return this.shootSpawnX; this.primaryShotImage = filename;
} }
protected int getShootSpawnY(){
return this.shootSpawnY;
}
protected int getShootDirection(){
return this.shootDirection;
}
protected int getShootSpeed(){
return this.shootSpeed;
}
} }

View File

@ -3,7 +3,6 @@ import java.util.Random;
import de.teamteamteam.spacescooter.entity.ShootingEntity; import de.teamteamteam.spacescooter.entity.ShootingEntity;
import de.teamteamteam.spacescooter.entity.shot.Shot; import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.entity.shot.SingleRedShot;
public abstract class Enemy extends ShootingEntity { public abstract class Enemy extends ShootingEntity {
@ -13,6 +12,7 @@ public abstract class Enemy extends ShootingEntity {
this.name = "EnemyOne"; this.name = "EnemyOne";
this.willShoot = r.nextBoolean(); this.willShoot = r.nextBoolean();
this.setShootDirection(Shot.LEFT); this.setShootDirection(Shot.LEFT);
this.setPrimaryShotImage("images/shot03.png");
} }
protected String name; protected String name;
@ -24,16 +24,6 @@ public abstract class Enemy extends ShootingEntity {
this.shoot(); this.shoot();
} }
@Override
public void createShot() {
new SingleRedShot(
super.getX() + super.getShootSpawnX(),
super.getY() + super.getShootSpawnY(),
super.getShootDirection(),
super.getShootSpeed(),
super.getDamageValue()
);
}
} }

View File

@ -3,7 +3,7 @@ package de.teamteamteam.spacescooter.entity.shot;
import de.teamteamteam.spacescooter.entity.LivingEntity; import de.teamteamteam.spacescooter.entity.LivingEntity;
import de.teamteamteam.spacescooter.utility.GameConfig; 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 RIGHT = 1;
public static final int LEFT= -1; public static final int LEFT= -1;
@ -14,19 +14,21 @@ public abstract class Shot extends LivingEntity {
private int speed; private int speed;
private int direction; 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); super(x, y);
this.direction = shootDirection; this.direction = shootDirection;
this.speed = shootSpeed; this.speed = shootSpeed;
this.collisionCount = 1; this.collisionCount = 1;
this.damageValue = damageValue; this.damageValue = damageValue;
}
public void setImage(String filename) {
super.setImage(filename); super.setImage(filename);
this.setPosition(this.x - this.getImage().getWidth() / 2, this.y - this.getImage().getHeight() / 2); 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() { public int getDamageValue() {
return this.damageValue; return this.damageValue;
} }

View File

@ -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");
}
}

View File

@ -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");
}
}

View File

@ -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");
}
}