Add Beam (Button: x)
This commit is contained in:
parent
df8077874c
commit
e4ebc31a1b
Binary file not shown.
After Width: | Height: | Size: 472 B |
|
@ -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--;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,9 +37,13 @@ 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
|
||||
public void createShot() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue