-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
24 changed files
with
174 additions
and
108 deletions.
There are no files selected for viewing
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
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
Empty file.
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 |
---|---|---|
@@ -1,26 +1,33 @@ | ||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) | ||
import greenfoot.Actor; | ||
import greenfoot.GreenfootImage; | ||
|
||
/** | ||
* Write a description of class Coin here. | ||
* | ||
* @author (your name) | ||
* | ||
* @author (your name) | ||
* @version (a version number or a date) | ||
*/ | ||
public class Coin extends Collection | ||
{ | ||
public class Coin extends Actor { | ||
private GreenfootImage image; | ||
|
||
public Coin(){ | ||
image = new GreenfootImage("coin.png"); | ||
image.scale(45,55); | ||
setImage(image); | ||
} | ||
|
||
|
||
/** | ||
* Act - do whatever the Coin wants to do. This method is called whenever | ||
* the 'Act' or 'Run' button gets pressed in the environment. | ||
*/ | ||
|
||
public void act() | ||
{ | ||
if (isTouching(Player.class)){ | ||
public void act() { | ||
if (isTouching(Player.class)) { | ||
getWorld().removeObject(this); | ||
Level.addToTotalCoin(); | ||
} | ||
} | ||
|
||
|
||
public boolean isBeingTouched() { | ||
return isTouching(Player.class); | ||
} | ||
} |
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
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
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
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,53 @@ | ||
import greenfoot.GreenfootImage; | ||
import greenfoot.World; | ||
|
||
public class Mites extends Mobs { | ||
private final int hp; | ||
private final int dmg; | ||
private final int speed; | ||
private final int direction = 1; | ||
private final GreenfootImage image; | ||
private Level w; | ||
private int movementAct; | ||
private int jumpAct; | ||
|
||
public Mites() { | ||
hp = 2; | ||
dmg = 1; | ||
speed = 2; | ||
image = new GreenfootImage("images/mites.png"); | ||
} | ||
|
||
public void addedToWorld(World w) { | ||
this.w = (Level) w; | ||
} | ||
|
||
public void act() { | ||
movementAct--; | ||
jumpAct--; | ||
movement(); | ||
bounceWall(); | ||
collision(); | ||
fall(); | ||
} | ||
|
||
private void flipImage() { | ||
image.mirrorHorizontally(); | ||
} | ||
|
||
private void fall() { | ||
if (getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Brick.class) == null && jumpAct < 15) { | ||
setLocation(getX() + (speed * direction), getY() + 5); | ||
} | ||
} | ||
|
||
private void movement() { | ||
if (movementAct < 0 && getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Brick.class) != null) { | ||
jumpAct = 30; | ||
movementAct = 60; | ||
} | ||
if (jumpAct > 15) { | ||
setLocation(getX() + (speed * direction), getY() - 5); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.