Skip to content

Commit

Permalink
Merge pull request #54 from Adrian400811/rc
Browse files Browse the repository at this point in the history
Enhancements and clean up
  • Loading branch information
Adrian400811 authored Jun 14, 2024
2 parents a0b6b26 + c6e21b7 commit a82df8e
Show file tree
Hide file tree
Showing 59 changed files with 805 additions and 561 deletions.
6 changes: 6 additions & 0 deletions Bee.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import greenfoot.World;

/**
* Bee Class
*
* @author Adrian, Jason
* @version June 13 2024
*/
public abstract class Bee extends Mobs {
private final int hp;
private final int speed;
Expand Down
11 changes: 9 additions & 2 deletions BlueBee.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import greenfoot.World;

/**
* BlueBee Class
*
* @author Adrian, Jason
* @version June 13 2024
*/
public class BlueBee extends Bee {
private final int speed;
private final int range;
private final int direction;
private World w;
private Level w;
private int[] anchor;

public BlueBee() {
Expand All @@ -15,12 +21,13 @@ public BlueBee() {
}

public void addedToWorld(World w) {
this.w = (Level) w;
super.addedToWorld(w);
anchor = new int[]{getX(), getY()};
}

public void act() {

movement();
collision();
super.act();
Expand Down
6 changes: 3 additions & 3 deletions Brick.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import greenfoot.GreenfootImage;

/**
* Write a description of class Block here.
* Block Class
*
* @author (your name)
* @version (a version number or a date)
* @author Adrian, Jimmy
* @version June 13 2024
*/
public class Brick extends Tile {
public Brick() {
Expand Down
6 changes: 3 additions & 3 deletions Button.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Button here.
* Button class for the game
*
* @author (your name)
* @version (a version number or a date)
* @author Jimmy
* @version June 13 2024
*/
public class Button extends Actor
{
Expand Down
18 changes: 10 additions & 8 deletions Coin.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import greenfoot.GreenfootImage;

/**
* Write a description of class Coin here.
* Coin class
*
* @author (your name)
* @version (a version number or a date)
* @author Jimmy, Daniel
* @version June 13 2024
*/
public class Coin extends Collection {
private final GreenfootImage image;

/**
* Constructor
*/
public Coin() {
image = new GreenfootImage("coin.png");
image.scale(45,45);
GreenfootImage image = new GreenfootImage("coin.png");
image.scale(45, 45);
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.
* Act - if touching Player, remove coin and add it to the total coins
*/
public void act() {
if (isTouching(Player.class)) {
playCollected();
getWorld().removeObject(this);
Level.addToTotalCoin();
}
Expand Down
31 changes: 28 additions & 3 deletions Collection.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Collection here.
* Collection Class
*
* @author (your name)
* @version (a version number or a date)
* @author Daniel, Adrian, Jimmy
* @version June 13 2024
*/
public class Collection extends SuperSmoothMover
{
protected GreenfootSound collected = new GreenfootSound("kaching.mp3");
protected static GreenfootSound[] collectedSound;
protected static int collectedSoundIndex;
/**
* Act - do whatever the Collection wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
Expand All @@ -16,4 +19,26 @@ public void act()
{
// Add your action code here.
}

/** Plays collected sound */
protected void playCollected() {
collectedSound[collectedSoundIndex].setVolume(50);
collectedSound[collectedSoundIndex].play();
collectedSoundIndex++;
if (collectedSoundIndex >= collectedSound.length) {
collectedSoundIndex = 0;
}
}

/** Pre-loads sounds for collected up From Mr.Cohen's Demo Tutorial */
protected static void init() {
collectedSoundIndex = 0;
collectedSound = new GreenfootSound[48];
for (int i = 0; i < collectedSound.length; i++) {
collectedSound[i] = new GreenfootSound("kaching.mp3");
collectedSound[i].play();
Greenfoot.delay(1);
collectedSound[i].stop();
}
}
}
18 changes: 10 additions & 8 deletions Crown.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import greenfoot.GreenfootImage;

/**
* Write a description of class Crown here.
* Crown class
*
* @author (your name)
* @version (a version number or a date)
* @author Daniel
* @version June 13 2024
*/
public class Crown extends Collection {
private final GreenfootImage image;

/**
* Constructor
*/
public Crown() {
image = new GreenfootImage("crown.png");
GreenfootImage image = new GreenfootImage("crown.png");
image.scale(64, 64);
setImage(image);
}

/**
* Act - do whatever the Crown wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
* Act - Removes from world if touching Player and adds it to totalCrowns
*/
public void act() {
if (isTouching(Player.class)){
if (isTouching(Player.class)) {
playCollected();
getWorld().removeObject(this);
Level.addCrown();
}
Expand Down
6 changes: 3 additions & 3 deletions Drone.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Drone here.
* Drone Class
*
* @author (your name)
* @version (a version number or a date)
* @author Daniel
* @version June 13 2024
*/
public class Drone extends FriendlyCreatures
{
Expand Down
62 changes: 31 additions & 31 deletions EndScreen.java
Original file line number Diff line number Diff line change
@@ -1,63 +1,55 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import greenfoot.*;

/**
* Write a description of class EndScreen here.
*
* @author (your name)
* @version (a version number or a date)
* End Screen for the game
*
* @author Jimmy
* @version June 13 2024
*/
public class EndScreen extends World
{
private final Font font = new Font("Arial", 64);
private final SuperDisplayLabel titleLabel = new SuperDisplayLabel(Color.WHITE, Color.BLACK, font);
private final GreenfootImage titleImage = new GreenfootImage("youWin.png");

private final SuperDisplayLabel gameOverLabel = new SuperDisplayLabel(font);
private final GreenfootImage gameOverImage = new GreenfootImage("gameOverInstructions.png");

private Crown crown = new Crown();

private GreenfootImage playerImage = new GreenfootImage("GuyR0.png");
private Button player = new Button();

public class EndScreen extends World {
/**
* Constructor for objects of class EndScreen.
*
*/
public EndScreen()
{
public EndScreen() {
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1280, 720, 1);


// Paint Order
setPaintOrder(SuperDisplayLabel.class, Crown.class, Button.class);

// Background
setBackground("brick.jpg");

// Title
Font font = new Font("Arial", 64);
SuperDisplayLabel titleLabel = new SuperDisplayLabel(Color.WHITE, Color.BLACK, font);
addObject(titleLabel, 600, 200);
GreenfootImage titleImage = new GreenfootImage("youWin.png");
titleLabel.setImage(titleImage);
titleLabel.setLocation(640, 150);

// Instruction Label
SuperDisplayLabel gameOverLabel = new SuperDisplayLabel(font);
addObject(gameOverLabel, getWidth() / 2, 600);
gameOverLabel.update("Press 'enter' to go to the Title Screen");
GreenfootImage gameOverImage = new GreenfootImage("gameOverInstructions.png");
gameOverImage.scale(1100, 60);
gameOverLabel.setImage(gameOverImage);
gameOverLabel.setLocation(getWidth() / 2, 600);

// Add a Crown
addObject(crown, getWidth()/2-5, getHeight()/2-78);

Crown crown = new Crown();
addObject(crown, getWidth() / 2 - 5, getHeight() / 2 - 78);

// Add player
playerImage.scale(140,150);
GreenfootImage playerImage = new GreenfootImage("GuyR0.png");
playerImage.scale(140, 150);
Button player = new Button();
player.setImage(playerImage);
addObject(player, getWidth()/2, getHeight()/2);
addObject(player, getWidth() / 2, getHeight() / 2);

}

public void act() {
checkKeys();
}
Expand All @@ -68,4 +60,12 @@ private void checkKeys() {
Greenfoot.setWorld(title);
}
}

public void stopped() {
TitleScreen.stopBGM();
}

public void started() {
TitleScreen.playBGM();
}
}
Empty file modified ExplodingRobot.java
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions FloorHole.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

import java.util.List;

/**
* FloorHole class
*
* @author Adrian
* @version June 13 2024
*/
public class FloorHole extends Actor {
public FloorHole() {
GreenfootImage image = new GreenfootImage(1, 1);
Expand Down
6 changes: 3 additions & 3 deletions FriendlyCreatures.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class FriendlyCreatures here.
* FriendlyCreatures Class
*
* @author (your name)
* @version (a version number or a date)
* @author Daniel
* @version June 13 2024
*/
public class FriendlyCreatures extends SuperSmoothMover
{
Expand Down
Loading

0 comments on commit a82df8e

Please sign in to comment.