Skip to content

Commit

Permalink
Merge branch 'rc' into Jimmy
Browse files Browse the repository at this point in the history
  • Loading branch information
349928465 authored Jun 13, 2024
2 parents 499706c + dffbedd commit 9b8d18c
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 38 deletions.
1 change: 1 addition & 0 deletions Bee.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void addedToWorld(World w) {

@Override
public void act() {
attackAct++;
attack(dmg);
collision();
super.act();
Expand Down
1 change: 1 addition & 0 deletions Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void followPlayer(ImgScroll scr, Player p) {
}
}


/**
* Updates the coin and hp and sets the location of it
*
Expand Down
4 changes: 2 additions & 2 deletions Level0.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Level0() {
addObject(player = new Player(), 100, 622);
addObject(coinLabel, 1100, 10);
addObject(saveButton, getWidth() - 100, 40);
updateCoin(coinLabel);
updateCoin();
resetCoin();
setHP(5);
setLevel(0);
Expand All @@ -34,7 +34,7 @@ public Level0() {

public void act() {
followPlayer(scroll, player);
updateCoin(coinLabel);
updateCoin();
saveButton.setLocation(getWidth() - 100, 40);
checkSaveButton();
checkNext();
Expand Down
14 changes: 7 additions & 7 deletions Level1.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Level1() {
addObject(player = new Player(), 130, 135);
addObject(coinLabel, 1100, 10);
addObject(saveButton, getWidth() - 100, 40);
updateCoin(coinLabel);
updateCoin();

// Individual Block Placement
int[][] blockGeneration = loadLevel(1);
Expand All @@ -32,17 +32,17 @@ public Level1() {

public void act() {
followPlayer(scroll, player);
updateCoin(coinLabel);
saveButton.setLocation(getWidth()-100, 40);
updateCoin();
saveButton.setLocation(getWidth() - 100, 40);
checkSaveButton();
loseLife();
checkNext();
}
private void loseLife(){
if (player.touchingSpike()){

private void loseLife() {
if (player.touchingSpike()) {
player.changeHP(-5);
setHP(totalHP-5);
setHP(totalHP - 5);
}
}
}
4 changes: 2 additions & 2 deletions Mites.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class Mites extends Mobs {
private final int dmg;
private final int speed;
private final GreenfootImage image;
private int direction = 1;
private Level w;
private int movementAct;
private int jumpAct;
Expand All @@ -33,8 +32,9 @@ public void addedToWorld(World w) {
public void act() {
movementAct--;
jumpAct--;
attackAct++;
movement();
direction = bounceWall(direction, image);
bounceWall(image);
collision();
fall();
attack(dmg);
Expand Down
40 changes: 17 additions & 23 deletions Mobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
*/

public abstract class Mobs extends SuperSmoothMover {
public World w;
private int hp;
private int speed = 2;
private int dmg;
private int direction = 1;
protected World w;
protected int attackAct = 0;
protected int direction = 1;
protected int hp;
protected int speed = 2;
protected int dmg;

/**
* Constructor
Expand All @@ -24,12 +25,20 @@ public Mobs() {
enableStaticRotation();
}

protected void bounceWall(GreenfootImage image) {
if (getOneObjectAtOffset(direction * getImage().getWidth() + 2, 0, Tile.class) != null) {
direction *= -1;
image.mirrorHorizontally();
}
}

public void addedToWorld(World w) {
this.w = w;
}

public void act() {
stepped();
attackAct++;
}

private void gravity() {
Expand Down Expand Up @@ -68,21 +77,6 @@ public void collision() {
}
}

protected int bounceWall(int dir) {
if (getOneObjectAtOffset(dir * getImage().getWidth() + 1, 0, Tile.class) != null) {
dir *= -1;
}
return dir;
}

protected int bounceWall(int dir, GreenfootImage image) {
if (getOneObjectAtOffset(dir * getImage().getWidth() + 2, 0, Tile.class) != null) {
dir *= -1;
image.mirrorHorizontally();
}
return dir;
}

protected void idle() {
if (getWorld() == null) {
return;
Expand Down Expand Up @@ -144,10 +138,10 @@ public void stepped() {
*/
public void attack(int dmg) {
Player p = (Player) getOneIntersectingObject(Player.class);
if (p == null) {
return;
if (p != null && attackAct > 60) {
attackAct = 0;
p.changeHP(-dmg);
}
p.changeHP(-dmg);
}

public void changeHP(int deltaHP) {
Expand Down
8 changes: 5 additions & 3 deletions Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Player extends Actor {
private static int speed;
private final int dmg;
private int hp;
private World w;
private Level w;
private int jumpActs = 0;
private int boostActs = 0;
private GreenfootImage[] R, L, U, D;
Expand Down Expand Up @@ -59,7 +59,7 @@ private void initAnim(){
}

public void addedToWorld(World w) {
this.w = w;
this.w = (Level) w;
}

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ private void fixDirections(){
private void jump() {
if (Greenfoot.isKeyDown("Space") && getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Brick.class) != null) {
jumpActs = 30;
}
}
if (jumpActs > 15) {
setLocation(getX(), getY() - 8);
}
Expand Down Expand Up @@ -228,7 +228,9 @@ public int getSpeed() {
*/
public void changeHP(int deltaHP) {
hp += deltaHP;
w.setHP(hp);
}


/**
* Returns if the Player is touching a Spike
Expand Down
1 change: 1 addition & 0 deletions Spider.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void addedToWorld(World w) {
}

public void act() {
attackAct++;
if (checkBlock() || checkY()) {
holdAct--;
hold();
Expand Down
2 changes: 1 addition & 1 deletion levels/0.csv
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
71,1,1
71,4,8
72,11,12
72,2,1
72,1,1
72,5,8
73,10,1
74,10,1
Expand Down

0 comments on commit 9b8d18c

Please sign in to comment.