Added a second boss

This commit is contained in:
Sosch 2015-01-18 13:21:47 +01:00
parent e5831e4c12
commit 88c6814984
26 changed files with 514 additions and 8 deletions

BIN
res/images/bossBig.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

BIN
res/images/bossGun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -19,4 +19,4 @@ spawn:EnemyTwo,1,10,60
spawn:EnemyThree,2,4,33 spawn:EnemyThree,2,4,33
spawn:EnemyTwo,5,6,10 spawn:EnemyTwo,5,6,10
[25-30] [25-30]
spawn:EnemyBoss,1,1,50 spawn:EnemyBigBoss,1,1,1

View File

@ -31,7 +31,7 @@ public abstract class Entity implements Updateable, Paintable {
/* Enemies */ /* Enemies */
EnemyOne, EnemyTwo, EnemyThree, EnemyFour, EnemyOne, EnemyTwo, EnemyThree, EnemyFour,
/* Boss Enemies and belongings */ /* Boss Enemies and belongings */
EnemyBoss, EnemyBossMinion, EnemyBoss, EnemyBossMinion, EnemyBigBoss,
/* Explosions */ /* Explosions */
ExplosionOne, ExplosionTwo, MultiExplosion, ExplosionOne, ExplosionTwo, MultiExplosion,
/* Stones */ /* Stones */
@ -222,4 +222,8 @@ public abstract class Entity implements Updateable, Paintable {
this.disposed = true; this.disposed = true;
} }
} }
public boolean isAlive() {
return !disposed;
}
} }

View File

@ -1,6 +1,5 @@
package de.teamteamteam.spacescooter.entity; package de.teamteamteam.spacescooter.entity;
import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;

View File

@ -0,0 +1,149 @@
package de.teamteamteam.spacescooter.entity.enemy;
import de.teamteamteam.spacescooter.brain.GameConfig;
import de.teamteamteam.spacescooter.entity.FlashImage;
import de.teamteamteam.spacescooter.entity.explosion.MultiExplosion;
import de.teamteamteam.spacescooter.entity.shot.BossBeamShooting;
import de.teamteamteam.spacescooter.entity.shot.BossEnemyTakeOff;
import de.teamteamteam.spacescooter.entity.shot.BossRocket;
import de.teamteamteam.spacescooter.gui.BossHealthBar;
import de.teamteamteam.spacescooter.screen.GameScreen;
import de.teamteamteam.spacescooter.utility.Random;
public class EnemyBigBoss extends Enemy{
private int move = 1;
private int moveTickCounter = 0;
private int shotTickCounter = 0;
private int nextShot = 500;
private int thisShot;
private int lastShot;
private FlashImage flashBossImage;
private BossBeamShooting bbs;
private BossEnemyTakeOff beto;
private EnemyBigBossHitbox[] hitbox = new EnemyBigBossHitbox[3];
private boolean hardmode = false;
public EnemyBigBoss(int x, int y) {
super(x, y);
this.setImage("images/bossBig.png");
this.setHealthPoints(8000);
this.setCollisionDamage(100);
this.setScore(10000);
this.setCollide(false);
this.willShoot = false;
this.hitbox[0] = new EnemyBigBossHitbox(409, 136, this);
this.hitbox[1] = new EnemyBigBossHitbox(192, 284, this);
this.hitbox[2] = new EnemyBigBossHitbox(74, 398, this);
new BossHealthBar(240, 5, this);
}
@Override
public void die() {
if(flashBossImage != null) flashBossImage.remove();
if(bbs != null) bbs.remove();
if(beto != null) beto.remove();
for(int i =0; i<3; i++){
hitbox[i].remove();
}
super.die();
}
/**
* Custom MultiExplosion for this enemy.
*/
@Override
public void explode() {
new MultiExplosion(this.getCenteredX()-2*96, this.getCenteredY());
new MultiExplosion(this.getCenteredX()-96, this.getCenteredY()-92);
new MultiExplosion(this.getCenteredX()-96, this.getCenteredY());
new MultiExplosion(this.getCenteredX()-96, this.getCenteredY()+92);
new MultiExplosion(this.getCenteredX(), this.getCenteredY()-2*92);
new MultiExplosion(this.getCenteredX(), this.getCenteredY()-92);
new MultiExplosion(this.getCenteredX(), this.getCenteredY());
new MultiExplosion(this.getCenteredX(), this.getCenteredY()+92);
new MultiExplosion(this.getCenteredX(), this.getCenteredY()+2*92);
new MultiExplosion(this.getCenteredX()+96, this.getCenteredY()-2*92);
new MultiExplosion(this.getCenteredX()+96, this.getCenteredY()-92);
new MultiExplosion(this.getCenteredX()+96, this.getCenteredY());
new MultiExplosion(this.getCenteredX()+96, this.getCenteredY()+92);
new MultiExplosion(this.getCenteredX()+96, this.getCenteredY()+2*92);
new MultiExplosion(this.getCenteredX()+2*96, this.getCenteredY()-92);
new MultiExplosion(this.getCenteredX()+2*96, this.getCenteredY());
new MultiExplosion(this.getCenteredX()+2*96, this.getCenteredY()+92);
}
@Override
public void update() {
super.update();
hitbox[0].setPosition(this.getCenteredX(), this.getCenteredY());
hitbox[1].setPosition(this.getCenteredX()+15, this.getCenteredY());
hitbox[2].setPosition(this.getCenteredX()+33, this.getCenteredY());
//Move into the Screen until it fits on X-Axis
if(this.getX() > GameConfig.gameScreenWidth+GameConfig.gameScreenXOffset-this.getImageWidth()) {
this.transpose(-1, 0);
}else if(this.moveTickCounter > 2){//Move up and down with half speed
//Move up or down within the GameScreen.
this.transpose(0, this.move);
if(bbs != null && bbs.isAlive()){
bbs.positionUpdate(move);
}
if(beto != null){
beto.positionUpdate(move);
}
if(this.getY() < GameConfig.gameScreenYOffset){
this.move = 1;
}
if(this.getY() > GameConfig.gameScreenHeight + GameConfig.gameScreenYOffset - this.getImageHeight()){
this.move = -1;
}
this.moveTickCounter = 0;
}else{
this.moveTickCounter++;
}
//Randomly fire
if(this.shotTickCounter == this.nextShot){
do{
thisShot = Random.nextInt(4);
}while(thisShot == lastShot);
lastShot = thisShot;
switch (thisShot) {
case 0://Fire the rocket
if(!hardmode){
if(GameScreen.getPlayer().getCenteredY() < this.getCenteredY()) new BossRocket(getCenteredX(), getCenteredY(), true);
else new BossRocket(getCenteredX(), getCenteredY(), false);
}else{
new BossRocket(getCenteredX(), getCenteredY(), true);
new BossRocket(getCenteredX(), getCenteredY(), false);
}
flashBossImage = new FlashImage(this.getCenteredX(), this.getCenteredY(), "images/bossBig.png", 12);
break;
case 1://Fire the beam
bbs = new BossBeamShooting(getX(), getY(), this, 0, hardmode);
break;
case 2://Fire the shot wave
bbs = new BossBeamShooting(getX(), getY(), this, 1, hardmode);
break;
case 3://Enemy take off
beto = new BossEnemyTakeOff(getCenteredX()-7, getY(), hardmode);
break;
}
if(getHealthPoints() >6000) this.nextShot = 400;
else if(getHealthPoints() >4000) this.nextShot = 300;
else if(getHealthPoints() >2000) this.nextShot = 250;
else{
this.nextShot = 200;
hardmode = true;
}
this.shotTickCounter = 0;
}else{
this.shotTickCounter++;
}
if(flashBossImage != null && flashBossImage.isAlive()) flashBossImage.setPosition(this.getX(), this.getY());
}
}

View File

@ -0,0 +1,35 @@
package de.teamteamteam.spacescooter.entity.enemy;
import de.teamteamteam.spacescooter.entity.LivingEntity;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
public class EnemyBigBossHitbox extends LivingEntity{
EnemyBigBoss enemyBigBoss;
public EnemyBigBossHitbox(int width, int height, EnemyBigBoss enemyBigBoss) {
super(0, 0);
this.setHitboxDimenstions(width, height);
this.enemyBigBoss = enemyBigBoss;
}
@Override
public void collideWith(Collidable entity) {
if(entity instanceof EnemyBigBossHitbox) return;
if(entity instanceof Shot){
Shot shot = (Shot) entity;
if(shot.getDirection() == Shot.LEFT) return;
enemyBigBoss.takeDamage(shot.getDamageValue());
}
if (entity instanceof Player) {
Player player = (Player) entity;
enemyBigBoss.takeDamage(player.getCollisionDamage());
}
}
@Override
public void explode() {}
}

View File

@ -63,9 +63,7 @@ public class EnemyFour extends Enemy{
nextPoint = points.get(index); nextPoint = points.get(index);
index++; index++;
neuerVektor(); neuerVektor();
}catch(IndexOutOfBoundsException e){ }catch(IndexOutOfBoundsException e){}
this.remove();
}
} }
@Override @Override

View File

@ -17,7 +17,7 @@ public class ItemNuke extends Item {
} }
/** /**
* Gives every enemy 20 damage. Most enemies do not survive this. * Gives every enemy 250 damage. Most enemies do not survive this.
*/ */
@Override @Override
public void itemCollected(Player player) { public void itemCollected(Player player) {
@ -26,7 +26,7 @@ public class ItemNuke extends Item {
while (entityIterator.hasNext()) { while (entityIterator.hasNext()) {
Entity entity = entityIterator.next(); Entity entity = entityIterator.next();
if(entity instanceof Enemy) { if(entity instanceof Enemy) {
((LivingEntity) entity).takeDamage(9001); ((LivingEntity) entity).takeDamage(250);
} }
} }
} }

View File

@ -0,0 +1,28 @@
package de.teamteamteam.spacescooter.entity.shot;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
public class BossBeam extends Shot{
private int lifetime = 0;
public BossBeam(int x, int y) {
super(x-240, y, Shot.LEFT, 0, 1, "images/shots/bossBeam.png");
}
@Override
public void update() {
this.lifetime++;
if(this.lifetime>100){
this.remove();
}
}
@Override
public void collideWith(Collidable entity) {}
public void positionUpdate(int y_delta){
this.transpose(0, y_delta);
}
}

View File

@ -0,0 +1,68 @@
package de.teamteamteam.spacescooter.entity.shot;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.enemy.EnemyBigBoss;
import de.teamteamteam.spacescooter.gui.ImageEntity;
public class BossBeamShooting extends Entity{
private int lifetime = 0;
private ImageEntity front1;
private ImageEntity front2;
private ImageEntity bossGun;
private ImageEntity bossImage;
private EnemyBigBoss boss;
private BossBeam bb;
private BossShotWave bsw;
private int mode;
private boolean hardmode;
public BossBeamShooting(int x, int y, EnemyBigBoss boss, int mode, boolean hardmode) {
super(x, y);
boss.setImage("images/bossBigShooting1.png");
this.boss = boss;
this.bossGun = new ImageEntity(getX()+10, getY()+190, "images/bossGun.png");
this.bossImage = new ImageEntity(x, y, "images/bossBigShooting1.png");
this.front1 = new ImageEntity(getX(), getY(), "images/bossBigShooting2.png");
this.front2 = new ImageEntity(getX(), getY(), "images/bossBigShooting3.png");
this.mode = mode;
this.hardmode = hardmode;
}
@Override
public void remove() {
front1.remove();
front2.remove();
bossGun.remove();
bossImage.remove();
if(bb != null) bb.remove();
super.remove();
}
@Override
public void update() {
this.lifetime++;
if(this.lifetime<40){
front1.transpose(0, -1);
front2.transpose(0, 1);
}else if(this.lifetime == 50){
if(mode == 0) bb = new BossBeam(this.getX(), this.getY()+200);
else bsw = new BossShotWave(this.getX()-10, this.getY()+200, hardmode);
}else if(this.lifetime>160 && this.lifetime<200){
front1.transpose(0, 1);
front2.transpose(0, -1);
}else if(this.lifetime == 200){
boss.setImage("images/bossBig.png");
this.remove();
}
}
public void positionUpdate(int y_delta){
front1.transpose(0, y_delta);
front2.transpose(0, y_delta);
bossGun.transpose(0, y_delta);
bossImage.transpose(0, y_delta);
if(bb != null && bb.isAlive()) bb.positionUpdate(y_delta);
if(bsw != null && bsw.isAlive()) bsw.positionUpdate(y_delta);
}
}

View File

@ -0,0 +1,90 @@
package de.teamteamteam.spacescooter.entity.shot;
import java.awt.Point;
import java.util.ArrayList;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.enemy.EnemyFour;
import de.teamteamteam.spacescooter.gui.ImageEntity;
import de.teamteamteam.spacescooter.screen.GameScreen;
public class BossEnemyTakeOff extends Entity{
private boolean hardmode;
private ImageEntity image1;
private ImageEntity image2;
private ImageEntity image3;
private ImageEntity image4;
private ImageEntity imageEnemyFour;
private int lifetime;
private ArrayList<Point> points = new ArrayList<Point>();
public BossEnemyTakeOff(int x, int y, boolean hardmode) {
super(x, y);
this.setImageDimensions(57, 399);
this.hardmode = hardmode;
this.image4 = new ImageEntity(x, y, "images/bossEnemyTakeOff4.png");
this.imageEnemyFour = new ImageEntity(getCenteredX()-10, getCenteredY()-15, "images/enemy01.png");
this.image2 = new ImageEntity(x, y, "images/bossEnemyTakeOff2.png");
this.image3 = new ImageEntity(x, y, "images/bossEnemyTakeOff3.png");
this.image1 = new ImageEntity(x, y, "images/bossEnemyTakeOff1.png");
}
@Override
public void remove() {
this.image1.remove();
this.image2.remove();
this.image3.remove();
this.image4.remove();
this.imageEnemyFour.remove();
super.remove();
}
@Override
public void update() {
this.lifetime++;
if(this.lifetime<40){
this.image2.transpose(0, -1);
this.image3.transpose(0, 1);
}else if(this.lifetime == 50){
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime == 65 && hardmode){
points.remove(0);
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime == 80){
points.remove(0);
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime == 95 && hardmode){
points.remove(0);
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime == 110){
points.remove(0);
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
if(!hardmode) imageEnemyFour.remove();
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime == 125 && hardmode){
points.remove(0);
points.add(new Point(GameScreen.getPlayer().getCenteredX(), GameScreen.getPlayer().getCenteredY()));
imageEnemyFour.remove();
new EnemyFour(getCenteredX()-10, getCenteredY()-15, points);
}else if(this.lifetime>160 && this.lifetime<200){
this.image2.transpose(0, 1);
this.image3.transpose(0, -1);
}else if(this.lifetime == 200){
this.remove();
}
}
public void positionUpdate(int y_delta){
this.image1.transpose(0, y_delta);
this.image2.transpose(0, y_delta);
this.image3.transpose(0, y_delta);
this.image4.transpose(0, y_delta);
this.imageEnemyFour.transpose(0, y_delta);
this.transpose(0, y_delta);
}
}

View File

@ -0,0 +1,57 @@
package de.teamteamteam.spacescooter.entity.shot;
import java.awt.Graphics2D;
import de.teamteamteam.spacescooter.entity.enemy.Enemy;
import de.teamteamteam.spacescooter.entity.enemy.EnemyBigBossHitbox;
import de.teamteamteam.spacescooter.entity.explosion.MultiExplosion;
import de.teamteamteam.spacescooter.entity.spi.Collidable;
import de.teamteamteam.spacescooter.screen.GameScreen;
public class BossRocket extends Shot {
private double rotation = 0;
private int lifeTime = 0;
public BossRocket(int x, int y, boolean upperRocket) {
super(x, y, Shot.LEFT, 3, 50, "images/shots/bossRocket.png");
if(upperRocket) this.setPosition(x-85, y-143);
else this.setPosition(x-85, y+93);
}
@Override
public void update(){
if(lifeTime > 30){
if(GameScreen.getPlayer().getCenteredY() < this.getCenteredY() - 20){
this.transpose(0, -1);
rotation = 0.1;
}else if(GameScreen.getPlayer().getCenteredY() > this.getCenteredY() + 20){
this.transpose(0, 1);
rotation = -0.1;
}else{
rotation = 0;
}
}
lifeTime++;
super.update();
}
@Override
public void paint(Graphics2D g) {
g.rotate(rotation);
super.paint(g);
g.rotate(-rotation);
}
@Override
public void collideWith(Collidable entity) {
if(entity instanceof EnemyBigBossHitbox) return;
super.collideWith(entity);
if(this.getDirection() == LEFT && entity instanceof Enemy) return;
new MultiExplosion(this.getX(), this.getCenteredY());
new MultiExplosion(this.getX()+(int)(this.getHitboxWidth()*0.25), this.getCenteredY());
new MultiExplosion(this.getCenteredX(), this.getCenteredY());
new MultiExplosion(this.getX()+(int)(this.getHitboxWidth()*0.75), this.getCenteredY());
new MultiExplosion(this.getX()+this.getHitboxWidth(), this.getCenteredY());
}
}

View File

@ -0,0 +1,40 @@
package de.teamteamteam.spacescooter.entity.shot;
public class BossShot extends Shot{
private double x;
private double y;
private double vektorX;
private double vektorY;
private int speed = 5;
private int counter;
private int mode;
public BossShot(int x, int y, int counter, int mode) {
super(x, y, Shot.LEFT, 0, 2, "images/shots/ballshot.png");
this.counter = counter;
this.x = x;
this.y = y;
this.mode = mode;
neuerVektor();
}
@Override
public void update() {
super.update();
this.x -= this.vektorX*this.speed;
this.y -= this.vektorY*this.speed;
this.setPosition((int)this.x, (int)this.y);
}
private void neuerVektor(){
this.vektorX = (this.getX());
if(mode == 0) this.vektorY = (this.getY() - (600-(counter*5)));
else this.vektorY = (this.getY() - (60+(counter*5)));
double laenge = Math.sqrt(this.vektorX * this.vektorX + this.vektorY * this.vektorY);
this.vektorX = vektorX/laenge;
this.vektorY = vektorY/laenge;
}
}

View File

@ -0,0 +1,34 @@
package de.teamteamteam.spacescooter.entity.shot;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.utility.Random;
public class BossShotWave extends Entity{
private int lifetime = 0;
private int rand;
private boolean hardmode;
public BossShotWave(int x, int y, boolean hardmode) {
super(x, y);
this.rand = Random.nextInt(2);
this.hardmode = hardmode;
}
@Override
public void update() {
this.lifetime++;
if(!hardmode) new BossShot(getX(), getY(), lifetime, rand);
else{
new BossShot(getX(), getY(), lifetime, 0);
new BossShot(getX(), getY(), lifetime, 1);
}
if(lifetime == 100) this.remove();
}
public void positionUpdate(int y_delta) {
this.transpose(0, y_delta);
}
}

View File

@ -15,6 +15,7 @@ import de.teamteamteam.spacescooter.datastructure.ConcurrentIterator;
import de.teamteamteam.spacescooter.entity.Entity; import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.Player; import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.entity.enemy.Enemy; import de.teamteamteam.spacescooter.entity.enemy.Enemy;
import de.teamteamteam.spacescooter.entity.enemy.EnemyBigBoss;
import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss; import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss;
import de.teamteamteam.spacescooter.entity.enemy.EnemyFour; import de.teamteamteam.spacescooter.entity.enemy.EnemyFour;
import de.teamteamteam.spacescooter.entity.enemy.EnemyOne; import de.teamteamteam.spacescooter.entity.enemy.EnemyOne;
@ -281,6 +282,9 @@ public final class Level {
case EnemyBoss: case EnemyBoss:
spawnedEntity = new EnemyBoss(x, y); spawnedEntity = new EnemyBoss(x, y);
break; break;
case EnemyBigBoss:
spawnedEntity = new EnemyBigBoss(x, y);
break;
case StoneOne: case StoneOne:
spawnedEntity = new StoneOne(x, y); spawnedEntity = new StoneOne(x, y);
break; break;