Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to rc
  • Loading branch information
ansxn committed Jun 13, 2024
2 parents 3f645ac + 91ef726 commit dbb2481
Show file tree
Hide file tree
Showing 69 changed files with 303 additions and 159 deletions.
18 changes: 11 additions & 7 deletions Brick.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import greenfoot.GreenfootImage;

/**
* Write a description of class Block here.
*
* @author (your name)
*
* @author (your name)
* @version (a version number or a date)
*/
public class Brick extends Tile
{
public class Brick extends Tile {
public Brick() {
GreenfootImage image = new GreenfootImage("brick.jpg");
image.scale(64, 64);
setImage(image);
}

/**
* Act - do whatever the Block wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
public void act() {
}
}
19 changes: 19 additions & 0 deletions Drone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Drone here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Drone extends FriendlyCreatures
{
/**
* Act - do whatever the Drone wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
19 changes: 19 additions & 0 deletions ExplodingRobot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class ExplodingRobot here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ExplodingRobot extends FriendlyCreatures
{
/**
* Act - do whatever the ExplodingRobot wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
19 changes: 19 additions & 0 deletions FloorHole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import greenfoot.Actor;
import greenfoot.GreenfootImage;
import greenfoot.World;

import java.util.List;

public class FloorHole extends Actor {
public FloorHole() {
GreenfootImage image = new GreenfootImage(1, 1);
setImage(image);
}

public void addedToWorld(World w) {
List<Brick> brick = getObjectsInRange(32, Brick.class);
for (Brick b : brick) {
w.removeObject(b);
}
}
}
19 changes: 19 additions & 0 deletions FriendlyCreatures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class FriendlyCreatures here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class FriendlyCreatures extends SuperSmoothMover
{
/**
* Act - do whatever the FriendlyCreatures wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}
7 changes: 4 additions & 3 deletions JumpBooster.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ public class JumpBooster extends Actor {

public JumpBooster() {
image = new GreenfootImage(64, 64);
image.setColor(new Color(63, 81, 181, 128));
image.fillRect(0, 0, 64, 64);
setImage(image);
}

public void addedToWorld(World w) {
image.setColor(new Color(63, 81, 181, 50));
image.drawRect(getX(), getY() + 30, 32, 2);
setImage(image);

}

public void act() {
Expand Down
28 changes: 20 additions & 8 deletions Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Level extends World {
protected static int totalCoins = 0;
protected static int totalHP = 5;
protected static int numOfCrown = 0;
private static int level = 0;
private final int[] worldSize = {2560, 720};
private final String background = "2dPixelForestBackground.png";
private final Font font = new Font("Arial", 18);
Expand All @@ -17,15 +18,22 @@ public class Level extends World {
protected Player player;
protected SuperDisplayLabel coinLabel = new SuperDisplayLabel(Color.BLACK, Color.WHITE, font);
protected Button saveButton = new Button();
private int level = 0;
private Orb orb;


public Level() {
super(1280, 720, 1, false);
saveButtonImage.scale(150, 60);
saveButton.setImage(saveButtonImage);
setPaintOrder(Button.class,SuperDisplayLabel.class,Tile.class);
setPaintOrder(Button.class, SuperDisplayLabel.class, Tile.class);
}

public Level(int level) {
super(1280, 720, 1, false);
saveButtonImage.scale(150, 60);
saveButton.setImage(saveButtonImage);
setPaintOrder(Button.class, SuperDisplayLabel.class, Tile.class);
setLevel(level);
}

public static void resetCoin() {
Expand All @@ -41,27 +49,30 @@ public static void addCrown() {
}

public void spawnFloor(ImgScroll sc) {
for (int j = 0; j < sc.getScrollHeight() - 100; j += 300) {
for (int i = 0; i < sc.getScrollWidth() + 64; i += 63) {
addObject(new Brick(), i, 700);
}
for (int i = 0; i < sc.getScrollWidth() + 64; i += 64) {
addObject(new Brick(), i, 700);
}
}

public void checkNext() {
if (orb.isBeingTouched()) {
if (level == 0){
if (level == 0) {
levelUp();
Level1 world = new Level1();
Greenfoot.setWorld(world);
return;
}
if (level == 1){
if (level == 1) {
EndScreen end = new EndScreen();
Greenfoot.setWorld(end);
}
}
}

public void setLevel(int level) {
Level.level = level;
}

public int[] getWorldSize() {
return worldSize;
}
Expand Down Expand Up @@ -127,6 +138,7 @@ public void spawnTerrain(int[][] identifier) {
case 9 -> new Crown();
case 10 -> new JumpBooster();
case 11 -> new Spike();
case 12 -> new FloorHole();
default -> null;
};
if (a != null) {
Expand Down
3 changes: 2 additions & 1 deletion Level0.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Level0() {
updateCoin(coinLabel);
resetCoin();
setHP(5);
setLevel(0);

int[][] blockGeneration = loadLevel(0);
spawnTerrain(blockGeneration);
Expand All @@ -34,7 +35,7 @@ public Level0() {
public void act() {
followPlayer(scroll, player);
updateCoin(coinLabel);
saveButton.setLocation(getWidth()-100, 40);
saveButton.setLocation(getWidth() - 100, 40);
checkSaveButton();
checkNext();
}
Expand Down
Empty file modified LoadSettings.java
100644 → 100755
Empty file.
12 changes: 9 additions & 3 deletions Mobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public Mobs() {
public void addedToWorld(World w) {
this.w = w;
}
public void act(){

public void act() {
stepped();
}

Expand Down Expand Up @@ -110,11 +111,16 @@ public Player getPlayer(int range) {
}
return null;
}
public void stepped(){
if(getOneObjectAtOffset(getX(), -(getImage().getHeight()/2), Player.class)!=null){

public void stepped() {
if (getWorld() == null) {
return;
}
if (getOneObjectAtOffset(getX(), -(getImage().getHeight() / 2), Player.class) != null) {
getWorld().removeObject(this);
}
}

public void attack(int dmg) {
Player p = (Player) getOneIntersectingObject(Player.class);
if (p == null) {
Expand Down
6 changes: 2 additions & 4 deletions Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ private void fixDirections(){
}

private void jump() {
if (Greenfoot.isKeyDown("Space") && getOneObjectAtOffset((getImage().getHeight() / 2), (getImage().getHeight() / 2) + 1, Brick.class) != null) {
if (Greenfoot.isKeyDown("Space") && getOneObjectAtOffset(0, (getImage().getHeight() / 2) + 1, Brick.class) != null) {
jumpActs = 30;
} else if (Greenfoot.isKeyDown("Space") && getOneObjectAtOffset(-(getImage().getHeight() / 2), (getImage().getHeight() / 2) + 1, Brick.class) != null) {
jumpActs = 30;
}
}
if (jumpActs > 15) {
setLocation(getX(), getY() - 8);
}
Expand Down
10 changes: 7 additions & 3 deletions Spider.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void addedToWorld(World w) {
}

public void act() {
if (checkBlock()) {
if (checkBlock() || checkY()) {
holdAct--;
hold();
} else {
Expand Down Expand Up @@ -61,15 +61,19 @@ private boolean checkBlock() {
return getOneIntersectingObject(Tile.class) != null;
}

private boolean checkY() {
return (getY() < 0 || getY() > w.getHeight());
}

public void timeout() {
if (w == null) {
return;
}
if (!oob && (getX() < 0 || getX() > w.getWidth() || getY() < 0 || getY() > w.getHeight())) {
if (!oob && (getX() < 0)) {
oob = true;
startTime = System.currentTimeMillis();
}
if (oob && !(getX() < 0 || getX() > w.getWidth() || getY() < 0 || getY() > w.getHeight())) {
if (oob && !(getX() < 0)) {
oob = false;
}
if (oob) {
Expand Down
Empty file modified Spike.java
100644 → 100755
Empty file.
Empty file modified doc/Bee.html
100644 → 100755
Empty file.
Empty file modified doc/BlueBee.html
100644 → 100755
Empty file.
Empty file modified doc/Brick.html
100644 → 100755
Empty file.
Empty file modified doc/Button.html
100644 → 100755
Empty file.
Empty file modified doc/Coin.html
100644 → 100755
Empty file.
Empty file modified doc/Collection.html
100644 → 100755
Empty file.
Empty file modified doc/Crown.html
100644 → 100755
Empty file.
Empty file modified doc/EndScreen.html
100644 → 100755
Empty file.
Empty file modified doc/GameOverScreen.html
100644 → 100755
Empty file.
Empty file modified doc/GreenBee.html
100644 → 100755
Empty file.
Empty file modified doc/ImgScroll.html
100644 → 100755
Empty file.
Empty file modified doc/Level.html
100644 → 100755
Empty file.
Empty file modified doc/Level0.html
100644 → 100755
Empty file.
Empty file modified doc/Level1.html
100644 → 100755
Empty file.
Empty file modified doc/Mites.html
100644 → 100755
Empty file.
Empty file modified doc/Mobs.html
100644 → 100755
Empty file.
Empty file modified doc/Orb.html
100644 → 100755
Empty file.
Empty file modified doc/RedBee.html
100644 → 100755
Empty file.
Empty file modified doc/Spider.html
100644 → 100755
Empty file.
Empty file modified doc/SuperDisplayLabel.html
100644 → 100755
Empty file.
Empty file modified doc/SuperSmoothMover.html
100644 → 100755
Empty file.
Empty file modified doc/Tile.html
100644 → 100755
Empty file.
Empty file modified doc/TitleScreen.html
100644 → 100755
Empty file.
Empty file modified doc/allclasses-index.html
100644 → 100755
Empty file.
Empty file modified doc/allpackages-index.html
100644 → 100755
Empty file.
Empty file modified doc/help-doc.html
100644 → 100755
Empty file.
Empty file modified doc/index-all.html
100644 → 100755
Empty file.
Empty file modified doc/jquery-ui.overrides.css
100644 → 100755
Empty file.
Empty file modified doc/member-search-index.js
100644 → 100755
Empty file.
Empty file modified doc/module-search-index.js
100644 → 100755
Empty file.
Empty file modified doc/overview-tree.html
100644 → 100755
Empty file.
Empty file modified doc/package-search-index.js
100644 → 100755
Empty file.
Empty file modified doc/package-tree.html
100644 → 100755
Empty file.
Empty file modified doc/resources/glass.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/resources/x.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified doc/script-dir/jquery-3.6.1.min.js
100644 → 100755
Empty file.
Empty file modified doc/script-dir/jquery-ui.min.css
100644 → 100755
Empty file.
Empty file modified doc/script-dir/jquery-ui.min.js
100644 → 100755
Empty file.
Empty file modified doc/search.js
100644 → 100755
Empty file.
Empty file modified doc/stylesheet.css
100644 → 100755
Empty file.
Empty file modified doc/tag-search-index.js
100644 → 100755
Empty file.
Empty file modified doc/type-search-index.js
100644 → 100755
Empty file.
Binary file added images/exploding robot/coolDown.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/exploding robot/exploding1.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/exploding robot/exploding2.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/exploding robot/normal1.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/exploding robot/normal2.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/exploding robot/normal3.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 removed images/marioCoin.png
Binary file not shown.
Empty file modified images/saveButtonImage.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified images/saveFile1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified images/saveFile2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified images/spikes.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 50 additions & 1 deletion levels/0.csv
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,53 @@
59,4,1
59,3,1
59,2,1
60,10,2
70,11,12
70,1,1
70,9,8
71,11,12
71,1,1
71,4,8
72,11,12
72,2,1
72,5,8
73,10,1
74,10,1
75,10,1
76,10,1
77,10,1
78,10,1
79,11,12
80,11,12
80,1,1
80,2,8
81,11,12
82,11,12
82,1,1
82,3,8
83,10,1
84,10,1
84,9,1
85,10,1
85,9,1
85,8,1
86,10,1
86,9,1
86,8,1
86,7,1
90,8,3
90,9,3
91,7,3
91,8,3
91,9,3
91,10,3
92,7,3
92,8,3
92,9,3
92,10,3
93,7,3
93,8,3
93,9,3
93,10,3
94,8,3
94,9,3
100,10,2
20 changes: 10 additions & 10 deletions levels/1.csv
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
17,6,1
16,6,1
15,6,1
3,10,10
4,10,10
6,10,10
7,10,10
11,10,10
12,10,10
3,10,11
4,10,11
6,10,11
7,10,11
11,10,11
12,10,11
15,7,1
15,8,1
18,2,1
Expand Down Expand Up @@ -100,8 +100,8 @@
23,8,1
28,2,1
29,2,1
30,10,10
31,10,10
30,10,11
31,10,11
29,3,1
29,4,1
29,5,1
Expand All @@ -113,8 +113,8 @@
32,10,1
32,9,1
32,8,1
33,10,10
34,10,10
33,10,11
34,10,11
35,10,1
35,9,1
35,8,1
Loading

0 comments on commit dbb2481

Please sign in to comment.