Comment the Shot class.
This commit is contained in:
parent
506a5ae620
commit
76b7b33938
|
@ -3,35 +3,70 @@ 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a Shot in the game.
|
||||||
|
* It takes care of its movements, contains information about its
|
||||||
|
* look and damage, and ends its life once it is out of the visible screen.
|
||||||
|
*/
|
||||||
public class Shot extends LivingEntity {
|
public class Shot extends LivingEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid value for shootDirection parameter.
|
||||||
|
* Makes the Shot travel to the right.
|
||||||
|
*/
|
||||||
public static final int RIGHT = 1;
|
public static final int RIGHT = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid value for shootDirection parameter.
|
||||||
|
* Makes the Shot travel to the left.
|
||||||
|
*/
|
||||||
public static final int LEFT= -1;
|
public static final int LEFT= -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much damage a shot will do to a LivingEntity that gets hit by it
|
||||||
|
*/
|
||||||
private int damageValue;
|
private int damageValue;
|
||||||
protected int collisionCount;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speed at which the shot travels.
|
||||||
|
*/
|
||||||
private int speed;
|
private int speed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direction in which the shot travels. May be Shot.LEFT or Shot.RIGHT.
|
||||||
|
*/
|
||||||
private int direction;
|
private int direction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Takes all information needed to create a new Shot object ready to hit things.
|
||||||
|
*/
|
||||||
public Shot(int x, int y, int shootDirection, int shootSpeed, int damageValue, String filename) {
|
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.damageValue = damageValue;
|
this.damageValue = damageValue;
|
||||||
this.setImage(filename);
|
this.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the damage this shot does to LivingEntities it hits.
|
||||||
|
*/
|
||||||
public int getDamageValue() {
|
public int getDamageValue() {
|
||||||
return this.damageValue;
|
return this.damageValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a new damage value for this shot.
|
||||||
|
*/
|
||||||
public void setDamageValue(int dmg) {
|
public void setDamageValue(int dmg) {
|
||||||
this.damageValue = dmg;
|
this.damageValue = dmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make the shot travel in the right direction.
|
||||||
|
* Remove the shot once out of the visible area.
|
||||||
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
this.x += this.direction * this.speed;
|
this.x += this.direction * this.speed;
|
||||||
//remove the shot in case it is out of the game window.
|
//remove the shot in case it is out of the game window.
|
||||||
|
|
Loading…
Reference in New Issue