-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b1ae0b
commit 19f436d
Showing
21 changed files
with
238 additions
and
108 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.