Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions animation/ArcadeDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,7 @@
import gameObjects.Player;
import gameObjects.Room;
import gameObjects.TextBox;
import rooms.CandleRoom;
import rooms.ColorButtonRoom;
import rooms.ColorRoom;
import rooms.CustomRoom;
import rooms.KamiRoomOne;
import rooms.MultiButtonRoom;
import rooms.RainbowRoom;
import rooms.RoomOne;
import rooms.RoomSearch;
import rooms.RushHourRoom;
//import rooms.RoomThree;
import rooms.MazeRoom;
import rooms.MysteryDoorRoom;
import rooms.RoomLetters;
import rooms.RoomWithDrawer;
import rooms.RoomWithRandomHiddenButton;
import rooms.RoomWithStuff;
import rooms.RoomZero;
import rooms.SafeRoom;
import rooms.TimedButtonRoom;
import rooms.initialRoom;
import rooms.lightswitchRoom;
import rooms.*;


public class ArcadeDemo extends AnimationPanel
Expand Down Expand Up @@ -85,6 +64,7 @@ public ArcadeDemo()
public void addRoomsToList()
{
rooms.add(new initialRoom());
rooms.add(new RoomSpotlight());
rooms.add(new MysteryDoorRoom());
rooms.add(new ColorButtonRoom());
rooms.add(new CandleRoom());
Expand All @@ -98,7 +78,7 @@ public void addRoomsToList()
rooms.add(new RoomZero());
rooms.add(new MultiButtonRoom());
rooms.add(new RoomWithStuff());
rooms.add(new KamiRoomOne());
//rooms.add(new KamiRoomOne());
rooms.add(new CustomRoom()); //good, not easy
rooms.add(new RoomLetters());
rooms.add(new RoomWithRandomHiddenButton()); //DIFFICULT!
Expand Down Expand Up @@ -131,13 +111,19 @@ protected Graphics renderFrame(Graphics g)
{
waitMode = true;
waitBeforeNextRoomTimer = 200;


victorySound.play();



}
if(waitMode)
{
if(waitBeforeNextRoomTimer > 0)
{
waitBeforeNextRoomTimer--;
g.drawImage(congrats ,0,-10,null);
g.drawImage(congrats ,0,-10,null);
}
else
{
Expand Down Expand Up @@ -287,11 +273,11 @@ public void initGraphics()
* 3. Add a line into the initMusic() function to load the clip.
* 4. Use the play(), stop() and loop() functions as needed in your code.
//-----------------------------------------------------------------------*/
AudioClip themeMusic;
AudioClip bellSound;
AudioClip victorySound;

public void initMusic()
public void initMusic()
{
victorySound = loadClip("src/sounds/victory.wav");
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
10 changes: 10 additions & 0 deletions gameObjects/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public void draw(Graphics g, ImageObserver io)
public static Image OImage;
public static Image UImage;
public static Image candleImage;

public static Image stageImage;
public static Image actorImage;
public static Image actorFlippedImage;

public static void loadImages(Toolkit toolkit)
{
Expand All @@ -129,6 +133,12 @@ public static void loadImages(Toolkit toolkit)
OImage = toolkit.getImage("src/items/images/O.gif");
UImage = toolkit.getImage("src/items/images/U.gif");
candleImage = toolkit.getImage("src/items/images/candle.gif");

stageImage = toolkit.getImage("src/items/images/stage.png");
actorImage = toolkit.getImage("src/items/images/actor.gif");
actorFlippedImage = toolkit.getImage("src/items/images/actor_flipped.gif");


}
public void reactToKey(char c, Player player) {
System.out.println("A key was pressed, but the Item has not overriden the reactToKey method");
Expand Down
36 changes: 36 additions & 0 deletions items/Performer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package items;

import gameObjects.Item;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;

/**
* Performer
* Walks back and forth across the stage in RoomSpotlight.
*
* by Tate McKenney
*/
public class Performer extends Item {

private int x = 70;
private int y = 200;
private int frameNumber = 0;


public Performer() {
super("Performer", new Rectangle(120, 200, 100, 172));
}


public void draw(Graphics g, ImageObserver io) {
if (frameNumber % 200 < 100)
g.drawImage(actorImage, x, y, io);
else
g.drawImage(actorFlippedImage, x, y, io);

x = (int) (270 - 120 * Math.cos(frameNumber * Math.PI / 100)); // move Performer back and forth horizontally
setRect(new Rectangle(x, y, 100, 172));
frameNumber++;
}
}
43 changes: 43 additions & 0 deletions items/Spotlight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package items;

import gameObjects.Item;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.ImageObserver;

/**
* Spotlight
* Follows the mouse cursor and draws a spotlight.
*
* by Tate McKenney
*/
public class Spotlight extends Item {

private int x; // x coordinate of center of spotlight
private int y; // y coordinate of center of spotlight


public Spotlight() {
super("Spotlight", new Rectangle());
}


// Moves the spotlight to the given position
public void setPosition(int xPos, int yPos) {
x = xPos;
y = yPos;
setRect(new Rectangle(x - 100, y - 100, 200, 200));
}


public void draw(Graphics g, ImageObserver io) {
g.setColor(new Color(255, 255, 64, 160));
g.fillOval(x - 100, y - 100, 200, 200);
}
}
Binary file added items/images/actor.gif
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 items/images/actor_flipped.gif
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 items/images/stage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions rooms/RoomSpotlight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package rooms;

import gameObjects.Room;
import items.BackgroundImage;
import static gameObjects.Item.stageImage;
import items.Performer;
import items.Spotlight;

/**
* RoomSpotlight
* by Tate McKenney
*
* Use the spotlight to follow the performer for eight seconds to progress to the next room.
*/
public class RoomSpotlight extends Room {

private int focusTime = 0; // number of frames that the spotlight has focused on the performer


public RoomSpotlight() {
super();
this.addItem(new BackgroundImage(stageImage));
this.addItem(new Spotlight());
this.addItem(new Performer());
}


public void updateMouseCoords(int x, int y) {
((Spotlight) getItemByName("Spotlight")).setPosition(x, y);
}


// Room ends when the spotlight has focused on the performer for 7 seconds
public boolean isDone() {
if (getItemByName("Spotlight").getRect().contains(getItemByName("Performer").getRect()))
focusTime++;
else
focusTime = 0;

return (focusTime > 240);
}


public String getHint() {
return "Follow the performer";
}
}
Binary file added sounds/victory.wav
Binary file not shown.