Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/rc' into Dz1
Browse files Browse the repository at this point in the history
# Conflicts:
#	Coin.java
#	project.greenfoot
  • Loading branch information
reihoron committed Jun 12, 2024
2 parents 8dbba68 + f8683b7 commit 4acc4f9
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 75 deletions.
19 changes: 0 additions & 19 deletions BlueSpider.java

This file was deleted.

10 changes: 4 additions & 6 deletions Coin.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import greenfoot.Actor;
import greenfoot.GreenfootImage;

/**
Expand All @@ -8,13 +7,13 @@
* @version (a version number or a date)
*/
public class Coin extends Collection {
private GreenfootImage image;
public Coin(){
private final GreenfootImage image;

public Coin() {
image = new GreenfootImage("coin.png");
image.scale(45,45);
setImage(image);

}

/**
Expand All @@ -26,6 +25,5 @@ public void act() {
getWorld().removeObject(this);
Level.addToTotalCoin();
}

}
}
8 changes: 7 additions & 1 deletion Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public int[][] loadLevel(int level) {
ArrayList<String> data = new ArrayList<String>();
Scanner scan = null;
try {
scan = new Scanner(new File("level" + level + ".csv"));
scan = new Scanner(new File("levels/" + level + ".csv"));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -89,6 +89,11 @@ public void spawnTerrain(int[][] identifier) {
case 1 -> new Brick();
case 2 -> orb = new Orb();
case 3 -> new Coin();
case 4 -> new Mites();
case 5 -> new BlueBee();
case 6 -> new RedBee();
case 7 -> new GreenBee();
case 8 -> new Spider();
default -> null;
};
if (a != null) {
Expand All @@ -98,3 +103,4 @@ public void spawnTerrain(int[][] identifier) {
}
}
}

5 changes: 0 additions & 5 deletions Level0.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ public Level0() {
addObject(coinLabel, 1100, 10);
coinLabel.update("Coins: " + totalCoins);


int[][] blockGeneration = loadLevel(0);
spawnTerrain(blockGeneration);
addObject(new BlueBee(), 800, 600);
addObject(new RedBee(), 100, 600);
addObject(new Spider(), 750, 600);
addObject(new Mites(), 150, 600);
}

public void act() {
Expand Down
2 changes: 1 addition & 1 deletion Level1.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Level1() {
coinLabel.update("Coins: " + totalCoins);

// Individual Block Placement
int[][] blockGeneration = new int[40][10];
int[][] blockGeneration = new int[120][20];
blockGeneration[2][5] = 1;
spawnTerrain(blockGeneration);
}
Expand Down
14 changes: 6 additions & 8 deletions Mites.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 int direction = 1;
private Level w;
private int movementAct;
private int jumpAct;
Expand All @@ -16,6 +16,8 @@ public Mites() {
dmg = 1;
speed = 2;
image = new GreenfootImage("images/mites.png");
image.scale(64, 43);
setImage(image);
}

public void addedToWorld(World w) {
Expand All @@ -26,23 +28,19 @@ public void act() {
movementAct--;
jumpAct--;
movement();
bounceWall();
direction = bounceWall(direction, image);
collision();
fall();
}

private void flipImage() {
image.mirrorHorizontally();
}

private void fall() {
if (getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Brick.class) == null && jumpAct < 15) {
if (getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Tile.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) {
if (movementAct < 0 && getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Tile.class) != null) {
jumpAct = 30;
movementAct = 60;
}
Expand Down
16 changes: 13 additions & 3 deletions Mobs.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import greenfoot.GreenfootImage;
import greenfoot.World;

import java.util.List;
Expand Down Expand Up @@ -53,10 +54,19 @@ public void collision() {
}
}

protected void bounceWall() {
if (getOneObjectAtOffset(direction * getImage().getWidth() + 1, 0, Brick.class) != null) {
direction *= -1;
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() {
Expand Down
27 changes: 0 additions & 27 deletions RedSpider.java

This file was deleted.

5 changes: 5 additions & 0 deletions Spider.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import greenfoot.GreenfootImage;
import greenfoot.World;

public class Spider extends Mobs {
private final int hp;
private final double speed;
private final int dmg;
private final GreenfootImage image;
private World w;
private int direction = 1;
private long startTime;
Expand All @@ -15,6 +17,9 @@ public Spider() {
hp = 2;
speed = 1;
dmg = 1;
image = new GreenfootImage("spider.png");
image.scale(47, 64);
setImage(image);
}

public void addedToWorld(World w) {
Expand Down
Binary file removed images/bricks.jpg
Binary file not shown.
Binary file modified images/mites.flip.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 modified images/mites.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/spider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions level0.csv

This file was deleted.

39 changes: 39 additions & 0 deletions levels/0.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
4,0,1
4,1,8
5,10,1
6,9,1
7,8,1
8,7,1
8,7,1
9,7,1
10,8,1
11,8,1
12,8,1
12,7,3
12,6,3
12,5,3
12,1,4
13,8,1
14,8,1
15,8,1
16,7,1
17,7,1
18,7,1
19,8,1
20,9,1
21,9,1
21,10,1
25,9,1
26,9,1
27,9,1
27,7,1
28,7,1
29,5,1
30,5,1
31,5,1
32,7,1
33,7,1
33,9,1
34,9,1
35,9,1
17,9,2
File renamed without changes.

0 comments on commit 4acc4f9

Please sign in to comment.