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
44 changes: 39 additions & 5 deletions animation/ArcadeDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected Graphics renderFrame(Graphics g)
{
started = true;
currentRoom++;
startMusic();
}
} else {

Expand All @@ -134,6 +135,8 @@ protected Graphics renderFrame(Graphics g)
{
waitMode = true;
waitBeforeNextRoomTimer = 200;
stopMusic();
victorySound.play();
}
if(waitMode)
{
Expand All @@ -150,6 +153,7 @@ protected Graphics renderFrame(Graphics g)
{
currentRoom++;
roomTime=0;
startMusic();
}
else
{
Expand Down Expand Up @@ -294,13 +298,43 @@ 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 song1;
AudioClip song2;
AudioClip victorySound;

public void initMusic()

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



// Begin playing the song for the current room
public void startMusic()
{
int songNo = rooms.get(currentRoom).getSong();
if (songNo == 1)
song1.loop();
else if (songNo == 2)
song2.loop();
else
song1.loop();
}


// Stop playing the current song
public void stopMusic()
{
int songNo = rooms.get(currentRoom).getSong();
if (songNo == 1)
song1.stop();
else if (songNo == 2)
song2.stop();
else
song1.stop();
}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}//--end of ArcadeDemo class--

8 changes: 7 additions & 1 deletion gameObjects/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ public String getHint()
{
return "Click on the door";
}

// Override this method to change which song plays in the room
public int getSong()
{
return 1;
}

public void draw(Graphics g, ImageObserver io)
{
Expand All @@ -108,4 +114,4 @@ public Item getItemByName(String s)
}
return null;
}
}
}
Binary file added sounds/song1.wav
Binary file not shown.
Binary file added sounds/song2.wav
Binary file not shown.
Binary file added sounds/victory.wav
Binary file not shown.