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 committed Jun 13, 2024
2 parents 7e5a0b2 + dbb2481 commit b7fb917
Show file tree
Hide file tree
Showing 90 changed files with 303 additions and 88 deletions.
Binary file added .DS_Store
Binary file not shown.
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
3 changes: 1 addition & 2 deletions Level1.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Level1 extends Level {
private final Player player;
private final int[] worldSize = {2700, 720};
private final String background = "2dSpaceBackground.png";
private Orb orb = new Orb();
private Orb orb;

/**
* Constructor for objects of class Level1.
Expand All @@ -28,7 +28,6 @@ public Level1() {
// Individual Block Placement
int[][] blockGeneration = loadLevel(1);
spawnTerrain(blockGeneration);
orb.setLocation(100,100);
}

public void act() {
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
86 changes: 85 additions & 1 deletion Player.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import greenfoot.Actor;
import greenfoot.Greenfoot;
import greenfoot.World;

import greenfoot.*;
/**
* Write a description of class Player here.
*
Expand All @@ -15,10 +15,45 @@ public class Player extends Actor {
private World w;
private int jumpActs = 0;
private int boostActs = 0;
private GreenfootImage[] R, L, U, D;
private boolean right, left, down, up, walking, isWaiting;
private int directionx, directiony;
protected int animIndex, animDelay, animCounter;

public Player() {
hp = 5;
dmg = 1;

R = new GreenfootImage[9];
L = new GreenfootImage[9];
U = new GreenfootImage[9];
D = new GreenfootImage[9];
for(int i = 0; i < R.length; i++){
R[i] = new GreenfootImage("GuyR" + i + ".png");
R[i].scale(70,75);
L[i] = new GreenfootImage("GuyL" + i + ".png");
L[i].scale(70,75);
U[i] = new GreenfootImage("GuyR" + i + ".png");
U[i].scale(70,75);
D[i] = new GreenfootImage("GuyR" + i + ".png");
D[i].scale(70,75);
}
animDelay = 3;
setImage(R[0]);

}
private void initAnim(){

directionx = 1;
directiony = 1;
walking = false;
right = true;
left = false;
up = false;
down = false;
animIndex = 0;
animDelay = 6;
animCounter = animDelay;
}

public void addedToWorld(World w) {
Expand All @@ -38,16 +73,41 @@ public void act() {
collision();
boundary();
checkHP();
animate();
fixDirections();
}

private void movement() {
if (Greenfoot.isKeyDown("D")) {
setLocation(getX() + 8, getY());
speed = 8;
directionx = 1;
}

if (Greenfoot.isKeyDown("A")) {
setLocation(getX() - 8, getY());
speed = -8;
directionx = -1;
}
if (Greenfoot.isKeyDown("D")|| Greenfoot.isKeyDown("A")) {
walking = true;
}
else{
walking = false;
directionx = -1;
}



}

private void fixDirections(){
if(directionx == 1){
right = true;
left = false;
} else{
left = true;
right = false;
}
}

Expand Down Expand Up @@ -109,6 +169,30 @@ private void collision() {
jumpActs = 0;
}
}

private void animate(){
if(walking){
if(animCounter == 0){
System.out.println("Changing frame.");
animCounter = animDelay;
animIndex++;
if(animIndex == R.length){
animIndex = 0;
}
} else{
animCounter--;
}
if(right){
setImage(R[animIndex]);
} else if(left){
setImage (L[animIndex]);
} else if (up){
setImage (U[animIndex]);
} else if (down){
setImage (D[animIndex]);
}
}
}

private void checkHP() {
if (hp <= 0) {
Expand Down
Loading

0 comments on commit b7fb917

Please sign in to comment.