Skip to content

Commit

Permalink
working ending
Browse files Browse the repository at this point in the history
  • Loading branch information
TheExploration committed May 15, 2023
1 parent 9b1ae0b commit 19f436d
Show file tree
Hide file tree
Showing 21 changed files with 238 additions and 108 deletions.
Binary file modified DelayWave.class
Binary file not shown.
5 changes: 3 additions & 2 deletions DelayWave.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public void act() {
if (deltaTime > delayTime) {

if (wave[i]!=null) {

level.MyWorld.addObject(wave[i], WaveManager.xOffset, (i%5)*level.ySpacing+level.yOffset);
level.zombieRow.get(i%5).add(wave[i]);

}
}

getWorld().removeObject(this);
return;
}
Expand Down
Binary file modified FixOrder.class
Binary file not shown.
7 changes: 6 additions & 1 deletion FixOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public void act() {
deltaTime = (currentFrame - lastFrame) / 1000000;
if (deltaTime > delayTime) {
level.fixOrder();
level.finishedSending = true;
if (level.wave == -1) {
level.finishedSending = true;
}



getWorld().removeObject(this);
return;
}
Expand Down
Binary file modified MyWorld.class
Binary file not shown.
8 changes: 5 additions & 3 deletions MyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MyWorld extends World
{new Conehead(), new Conehead(), new Conehead(), new BasicZombie(), new BasicZombie(), new Buckethead(), null, new BasicZombie(), new Conehead(), new Buckethead()}
};
public Zombie[][] level2 = {
{null, new BasicZombie(), null, null},
{null, new BasicZombie(), null, null}
};

Expand All @@ -48,7 +49,7 @@ public class MyWorld extends World
public Shovel shovel = new Shovel();


public WaveManager level = new WaveManager(23500L, level1, 10000L, true, 8, 20);
public WaveManager level = new WaveManager(23500L, level2, 10000L, true, 8, 20);



Expand All @@ -73,6 +74,8 @@ public void moveHitbox() {
public void finishLevel() {
Grasswalk.stop();
AudioPlayer.play(70, "winmusic.mp3");


}

public boolean hasLost() {
Expand Down Expand Up @@ -152,9 +155,8 @@ public void act() {
addObject(new Transition(false, new GameOver(), "gameover.png", 5), 365, 215);
}
if (!winOnce && hasWon()) {
Grasswalk.stop();
winOnce = true;
addObject(new MoneyBag(), Random.Int(SeedBank.x1, SeedBank.x2), 215);
addObject(new WinRepeater(), Random.Int(SeedBank.x1, SeedBank.x2), 215);
}

}
Expand Down
Binary file added Repeater.class
Binary file not shown.
10 changes: 10 additions & 0 deletions Repeater.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#BlueJ class context
comment0.target=Repeater
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Repeater\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=Repeater()
comment2.params=dmg
comment2.target=void\ hit(int)
comment3.params=
comment3.target=void\ update()
numComments=4
87 changes: 87 additions & 0 deletions Repeater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Repeater here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Repeater extends Plant
{
/**
* Act - do whatever the Repeater wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment. */
private GreenfootImage[] idle;
private GreenfootImage[] shoot;
private boolean shootOnce = false;
private boolean shooting = false;
private long shootDelay = 1700L;
private long lastFrame2 = System.nanoTime();
private long deltaTime2;

public Repeater() {
maxHp = 60;
hp = maxHp;
shoot = importSprites("repeatershoot", 2);
idle = importSprites("repeater", 5);
}

public void hit(int dmg) {
if (isLiving()) {
if (!shootOnce) {
hitFlash(idle, "peashooter");
} else {
hitFlash(shoot, "peashootershoot");

}
hp = hp-dmg;
}
}
public void update() {
MyWorld = (MyWorld)getWorld();
currentFrame = System.nanoTime();
if (!shooting) {
animate(idle, 150, true);
lastFrame2 = System.nanoTime();
} else {

deltaTime2 = (currentFrame - lastFrame2) / 1000000;
if (deltaTime2 < shootDelay) {
animate(idle, 150, true);
shootOnce = false;
} else {
if (!shootOnce) {
shootOnce = true;
frame = 0;

}

if (frame >= 3) {
AudioPlayer.play(80, "throw.mp3", "throw2.mp3");
MyWorld.addObject(new Pea(getYPos()), getX()+25,getY()-17);
lastFrame2 = currentFrame;
}
animate(shoot, 100, false);


}


}
if (MyWorld.level.zombieRow.get(getYPos()).size() == 0) {
shooting = false;
} else {

for (Zombie i : MyWorld.level.zombieRow.get(getYPos())) {
if (i.getX() > getX() && i.getX()<=MyWorld.getWidth()+10){
shooting = true;
break;
} else {
shooting = false;
}
}

}
}

}
Binary file modified WaveManager.class
Binary file not shown.
9 changes: 4 additions & 5 deletions WaveManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class WaveManager extends Actor
public long lastFrame2 = System.nanoTime();
public boolean won = false;
public World MyWorld;
private int wave = -1;
public int wave = -1;
public boolean first = false;
public boolean finishedSending = false;
public int[] hugeWaves;
Expand Down Expand Up @@ -158,7 +158,6 @@ public void sendWave(Zombie[] wave) {

for (int i = 0; i < wave.length; i++) {
if (i < 5) {
finishedSending = true;
if (wave[i]!=null) {
//Send!

Expand Down Expand Up @@ -199,13 +198,13 @@ public void sendWave(Zombie[] wave) {
public void sendHugeWave(Zombie[] wave) {

for (int i = 0; i < wave.length; i++) {

finishedSending = false;

//If more then 1 zombie per row, delay depending on how many
if (wave[i] != null) {
finishedSending = false;
int wait = (int)(i/5);
long delayTime = (long)(wait*8000L + 4000L);
long delayTime = (long)(wait*4000L + 8000L);
MyWorld.addObject(new DelayWave(wave, i, this, delayTime), 0,0);
}

Expand All @@ -226,7 +225,7 @@ public void sendHugeWave(Zombie[] wave) {
fix.schedule(new FixOrder(this), fixTime);*/


long fixTime = (long)(8055L+(wave.length-1)/5*4000L);
long fixTime = (long)(8050L+(wave.length-1)/5*4000L);

MyWorld.addObject(new FixOrder(this, fixTime), 0,0);
}
Expand Down
Binary file modified WinRepeater.class
Binary file not shown.
3 changes: 3 additions & 0 deletions WinRepeater.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public void update() {
deltaTime = (currentFrame - lastFrame) / 1000000;
if (move) {
setImage("repeaterpacket1.png");


if (getX() < (getWorld().getWidth()/2-5)) {
move(2);
} else if (getX() > (getWorld().getWidth()/2+5)){
Expand All @@ -34,6 +36,7 @@ public void update() {
if (!addTrans) {
addTrans=true;
getWorld().addObject(new Transition(false, new IntroLevel2(), "whitetransition.png", 1), 360, 215);
AudioPlayer.play(70, "lightfill.mp3");
}
}
} else {
Expand Down
Binary file added images/repeater1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeater2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeater3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeater4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeater5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeatershoot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/repeatershoot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 19f436d

Please sign in to comment.