- 6 stages + blitz stage

- waves re-arranged and timed with fire delay, launch delay, enemy lives, and number of enemies
This commit is contained in:
Matan 2016-03-20 20:18:20 +02:00
parent babeb3e370
commit 6bb97c19c1
10 changed files with 337 additions and 88 deletions

View file

@ -173,16 +173,25 @@ public class GameEngine {
stage.removeKeyListener(scene);
switch (currentLevel){
case 0:
scene = new FirstStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 1.0 =-", new int[]{5, 1,1,1});
scene = new FirstStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 1.0 =-", new int[]{5, 5});
break;
case 1:
scene = new SecondStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 2.0 =-", new int[]{5, 5,5,5});
scene = new SecondStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 2.0 =-", new int[]{5, 5,5});
break;
case 2:
scene = new ThirdStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 3.0 =-", new int[]{5, 0,0,8});
scene = new ThirdStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 3.0 =-", new int[]{5, 0,2,8});
break;
case 3:
scene = new FourthStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 4.0 =-", new int[]{5, 0,0,8});
scene = new FourthStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 4.0 =-", new int[]{5, 0,0,7});
break;
case 4:
scene = new FifthStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 5.0 =-", new int[]{5, 1,3,8, 10, 10});
break;
case 5:
scene = new SixthStage(pWidth, pHeight, numOfPlayers, this, "-= STAGE 6.0 =-", new int[]{5, 0,0,0, 0, 0, 10, 20});
break;
case 6:
scene = new BlitzStage(pWidth, pHeight, numOfPlayers, this, "-= BLITZ STAGE =-", new int[]{5, 0,0,0, 0, 0, 0, 0, 0, 0, 0});
break;
}

View file

@ -0,0 +1,91 @@
package com.sagi.dayan.Games.Stage;
import com.sagi.dayan.Games.Elements.Wave;
import com.sagi.dayan.Games.Engine.GameEngine;
import com.sagi.dayan.Games.Utils.WaveConfig;
import com.sagi.dayan.Games.Utils.WaveConfigs;
/**
* Created by sagi on 3/19/16.
*/
public class BlitzStage extends Level{
protected final int NUM_OF_WAVES = 4;
public BlitzStage(int width, int height, int numOfPlayers, GameEngine engine, String stageTitle, int[] waveDelay) {
super(width, height, numOfPlayers, engine, stageTitle, waveDelay);
numOfWaves = NUM_OF_WAVES;
}
@Override
protected void launchWave(long now) {
lastWaveTime = now;
System.out.println("New Wave!! " + currentWave + ", Time: " + now);
WaveConfig wc;
int numOfEnemies = 5, numOfHits = 1;
double launchDelay = 0.5, fireDelay = 5;
switch (currentWave){
case 0:
numOfEnemies = 35;
fireDelay = 0.5;
launchDelay = 0.5;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 1:
numOfEnemies = 35;
fireDelay = 0.3;
launchDelay = 0.5;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(1);
break;
case 2:
numOfEnemies = 45;
fireDelay = 0.3;
launchDelay = 0.5;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
case 3:
numOfEnemies = 45;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(3);
break;
case 4:
numOfEnemies = 55;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(4);
break;
case 5:
numOfEnemies = 55;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(5);
break;
case 6:
numOfEnemies = 65;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
case 7:
numOfEnemies = 65;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 10;
wc = engine.getWaveConfigs().getWaveConfig(7);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);
break;
}
waves.add(new Wave(numOfEnemies, wc.getMoveVector(), fireDelay, wc.getStepDelay(), launchDelay, wc.getAcc(), "L1-ES1.png", wc.getStartX(), wc.getStartY(), this, numOfHits));
currentWave++;
}
}

View file

@ -0,0 +1,77 @@
package com.sagi.dayan.Games.Stage;
import com.sagi.dayan.Games.Elements.Wave;
import com.sagi.dayan.Games.Engine.GameEngine;
import com.sagi.dayan.Games.Utils.WaveConfig;
import com.sagi.dayan.Games.Utils.WaveConfigs;
/**
* Created by sagi on 3/19/16.
*/
public class FifthStage extends Level{
protected final int NUM_OF_WAVES = 4;
public FifthStage(int width, int height, int numOfPlayers, GameEngine engine, String stageTitle, int[] waveDelay) {
super(width, height, numOfPlayers, engine, stageTitle, waveDelay);
numOfWaves = NUM_OF_WAVES;
}
@Override
protected void launchWave(long now) {
lastWaveTime = now;
System.out.println("New Wave!! " + currentWave + ", Time: " + now);
WaveConfig wc;
int numOfEnemies = 5, numOfHits = 1;
double launchDelay = 0.5, fireDelay = 5;
switch (currentWave){
case 0:
numOfEnemies = 15;
fireDelay = 0.3;
launchDelay = 0.7;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(1);
break;
case 1:
numOfEnemies = 15;
fireDelay = 0.3;
launchDelay = 0.7;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(4);
break;
case 2:
numOfEnemies = 20;
fireDelay = 0.3;
launchDelay = 0.7;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(5);
break;
case 3:
numOfEnemies = 25;
fireDelay = 0.3;
launchDelay = 0.7;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 4:
numOfEnemies = 35;
fireDelay = 0.2;
launchDelay = 0.5;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(3);
break;
case 5:
numOfEnemies = 35;
fireDelay = 0.1;
launchDelay = 0.3;
numOfHits = 5;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);
break;
}
waves.add(new Wave(numOfEnemies, wc.getMoveVector(), fireDelay, wc.getStepDelay(), launchDelay, wc.getAcc(), "L1-ES1.png", wc.getStartX(), wc.getStartY(), this, numOfHits));
currentWave++;
}
}

View file

@ -10,7 +10,7 @@ import com.sagi.dayan.Games.Utils.WaveConfigs;
*/
public class FirstStage extends Level{
protected final int NUM_OF_WAVES = 4;
protected final int NUM_OF_WAVES = 2;
public FirstStage(int width, int height, int numOfPlayers, GameEngine engine, String stageTitle, int[] waveDelay) {
super(width, height, numOfPlayers, engine, stageTitle, waveDelay);
@ -27,31 +27,24 @@ public class FirstStage extends Level{
switch (currentWave){
case 0:
numOfEnemies = 5;
fireDelay = 0.1;
launchDelay = 0.5;
fireDelay = 1.1;
launchDelay = 2;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(6);
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 1:
numOfEnemies = 5;
fireDelay = 1;
launchDelay = 1;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(3);
fireDelay = 0.8;
launchDelay = 2;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(1);
break;
case 2:
numOfEnemies = 10;
fireDelay = 0.8;
launchDelay = 1;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
case 3:
numOfEnemies = 15;
fireDelay = 1.5;
launchDelay = 1;
numOfHits = 5;
wc = engine.getWaveConfigs().getWaveConfig(7);
fireDelay = 0.7;
launchDelay = 1.5;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);

View file

@ -26,30 +26,30 @@ public class FourthStage extends Level{
double launchDelay = 0.5, fireDelay = 5;
switch (currentWave){
case 0:
numOfEnemies = 5;
numOfEnemies = 10;
fireDelay = 0.5;
launchDelay = 0.5;
launchDelay = 1;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(6);
wc = engine.getWaveConfigs().getWaveConfig(3);
break;
case 1:
numOfEnemies = 5;
numOfEnemies = 15;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(3);
launchDelay = 0.8;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
case 2:
numOfEnemies = 10;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(2);
launchDelay = 0.7;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 3:
numOfEnemies = 15;
numOfEnemies = 5;
fireDelay = 0.2;
launchDelay = 1;
launchDelay = 0.7;
numOfHits = 5;
wc = engine.getWaveConfigs().getWaveConfig(7);
break;

View file

@ -170,8 +170,8 @@ public abstract class Level extends Scene {
System.out.println("Done");
engine.changeLevel();
}
for(int i =0; i<blasts.size();i++){
if (blasts.get(i).isDone()){
System.out.println("removing blast");
@ -217,13 +217,11 @@ public abstract class Level extends Scene {
players.get(0).setvDirection(0);
}
if(keys.get(engine.getP1Controlles()[GameEngine.FIRE]) ){
if(players.get(0).isAbleToFire() && !players.get(0).isGameOver()) {
p1Missiles.add(new Missile(players.get(0).getCenterX() - 15, (int) players.get(0).getLocY(), getStageWidth(), getStageHeight(), players.get(0).getAcceleration() + 3, "P1Laser.png", 4));
if(players.get(0).isAbleToFire() && !players.get(0).isGameOver()){
p1Missiles.add(new Missile(players.get(0).getCenterX() - 15, (int)players.get(0).getLocY(),getStageWidth(),getStageHeight(), players.get(0).getAcceleration() + 3, "P1Laser.png", 4));
players.get(0).updateFireTime();
}
}
if(keys.get(engine.getP1Controlles()[GameEngine.USE_CREDIT]) && engine.getP1Health() <= 0 ){
if(engine.getCredits() > 0) {
if(engine.getP1Health() <= 0 && engine.getCredits() > 0) {
engine.revivePlayer(0);
players.get(0).resetPlayer();
@ -257,9 +255,7 @@ public abstract class Level extends Scene {
p2Missiles.add(new Missile(players.get(1).getCenterX() - 15, (int)players.get(1).getLocY(),getStageWidth(),getStageHeight(),players.get(1).getAcceleration() + 3, "P1Laser.png", 4));
players.get(1).updateFireTime();
}
}
if(keys.get(engine.getP2Controlles()[GameEngine.USE_CREDIT]) && engine.getP2Health() <= 0 ){
if(engine.getCredits() > 0) {
if(engine.getP2Health() <= 0 && engine.getCredits() > 0) {
engine.revivePlayer(1);
players.get(1).resetPlayer();
@ -299,7 +295,7 @@ public abstract class Level extends Scene {
if (isGameOver())
{
{
try {
System.in.read();
} catch (IOException e) {
@ -375,7 +371,7 @@ public abstract class Level extends Scene {
for(int i = 0 ; i < waves.size() ; i++){
waves.get(i).render(g,p);
}
for(int i =0; i<blasts.size();i++){
blasts.get(i).drawSprite(g, p);
}
@ -457,7 +453,7 @@ public abstract class Level extends Scene {
eMTR.add(enemyMissiles.get(j));
}else{
blasts.add(new Blast((int)players.get(i).getLocX(),(int)players.get(i).getLocY(),"explosion.png",15));
}
}
}
@ -474,7 +470,7 @@ public abstract class Level extends Scene {
waves.get(j).enemyHit(waves.get(j).getEnemies().get(k));
}else{
blasts.add(new Blast((int)players.get(i).getLocX(),(int)players.get(i).getLocY(),"explosion.png",15));
}
}
}

View file

@ -10,7 +10,7 @@ import com.sagi.dayan.Games.Utils.WaveConfigs;
*/
public class SecondStage extends Level{
protected final int NUM_OF_WAVES = 4;
protected final int NUM_OF_WAVES = 3;
public SecondStage(int width, int height, int numOfPlayers, GameEngine engine, String stageTitle, int[] waveDelay) {
super(width, height, numOfPlayers, engine, stageTitle, waveDelay);
@ -27,31 +27,31 @@ public class SecondStage extends Level{
switch (currentWave){
case 0:
numOfEnemies = 5;
fireDelay = 0.5;
launchDelay = 0.5;
fireDelay = 1;
launchDelay = 2;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
case 1:
numOfEnemies = 5;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(3);
break;
case 2:
case 1:
numOfEnemies = 10;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(2);
fireDelay = 0.8;
launchDelay = 1.5;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(4);
break;
case 2:
numOfEnemies = 15;
fireDelay = 0.7;
launchDelay = 1.3;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(5);
break;
case 3:
numOfEnemies = 15;
fireDelay = 0.2;
numOfEnemies = 20;
fireDelay = 0.6;
launchDelay = 1;
numOfHits = 5;
wc = engine.getWaveConfigs().getWaveConfig(7);
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);

View file

@ -0,0 +1,84 @@
package com.sagi.dayan.Games.Stage;
import com.sagi.dayan.Games.Elements.Wave;
import com.sagi.dayan.Games.Engine.GameEngine;
import com.sagi.dayan.Games.Utils.WaveConfig;
import com.sagi.dayan.Games.Utils.WaveConfigs;
/**
* Created by sagi on 3/19/16.
*/
public class SixthStage extends Level{
protected final int NUM_OF_WAVES = 4;
public SixthStage(int width, int height, int numOfPlayers, GameEngine engine, String stageTitle, int[] waveDelay) {
super(width, height, numOfPlayers, engine, stageTitle, waveDelay);
numOfWaves = NUM_OF_WAVES;
}
@Override
protected void launchWave(long now) {
lastWaveTime = now;
System.out.println("New Wave!! " + currentWave + ", Time: " + now);
WaveConfig wc;
int numOfEnemies = 5, numOfHits = 1;
double launchDelay = 0.5, fireDelay = 5;
switch (currentWave){
case 0:
numOfEnemies = 25;
fireDelay = 0.5;
launchDelay = 0.5;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
case 1:
numOfEnemies = 25;
fireDelay = 0.3;
launchDelay = 0.5;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(1);
break;
case 2:
numOfEnemies = 30;
fireDelay = 0.3;
launchDelay = 0.5;
numOfHits = 3;
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 3:
numOfEnemies = 15;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 4;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
case 4:
numOfEnemies = 35;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 4;
wc = engine.getWaveConfigs().getWaveConfig(6);
break;
case 5:
numOfEnemies = 35;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 4;
wc = engine.getWaveConfigs().getWaveConfig(4);
break;
case 6:
numOfEnemies = 35;
fireDelay = 0.2;
launchDelay = 0.4;
numOfHits = 4;
wc = engine.getWaveConfigs().getWaveConfig(7);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);
break;
}
waves.add(new Wave(numOfEnemies, wc.getMoveVector(), fireDelay, wc.getStepDelay(), launchDelay, wc.getAcc(), "L1-ES1.png", wc.getStartX(), wc.getStartY(), this, numOfHits));
currentWave++;
}
}

View file

@ -46,7 +46,6 @@ public class Stage extends JPanel implements Runnable{
@Override
public void paintComponent(Graphics g) {
// System.out.println("Paint Component");
super.paintComponent(g);
g.drawImage(engine.getScene(),0,0,this);
g.dispose();

View file

@ -26,32 +26,32 @@ public class ThirdStage extends Level{
double launchDelay = 0.5, fireDelay = 5;
switch (currentWave){
case 0:
numOfEnemies = 5;
fireDelay = 0.5;
launchDelay = 0.5;
numOfEnemies = 10;
fireDelay = 0.8;
launchDelay = 1.5;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(6);
wc = engine.getWaveConfigs().getWaveConfig(7);
break;
case 1:
numOfEnemies = 5;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(3);
break;
case 2:
numOfEnemies = 10;
fireDelay = 0.3;
launchDelay = 1;
numOfHits = 3;
numOfEnemies = 15;
fireDelay = 0.7;
launchDelay = 1.4;
numOfHits = 1;
wc = engine.getWaveConfigs().getWaveConfig(2);
break;
case 2:
numOfEnemies = 25;
fireDelay = 0.5;
launchDelay = 1.4;
numOfHits = 2;
wc = engine.getWaveConfigs().getWaveConfig(0);
break;
case 3:
numOfEnemies = 15;
fireDelay = 0.2;
numOfEnemies = 5;
fireDelay = 0.4;
launchDelay = 1;
numOfHits = 5;
wc = engine.getWaveConfigs().getWaveConfig(7);
numOfHits = 4;
wc = engine.getWaveConfigs().getWaveConfig(1);
break;
default:
wc = engine.getWaveConfigs().getWaveConfig(WaveConfigs.DEMO);