Skip to content

Commit

Permalink
Changes to implement the sound control.
Browse files Browse the repository at this point in the history
  • Loading branch information
Foo committed Jun 17, 2016
1 parent 3d77dea commit 6c95155
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
9 changes: 3 additions & 6 deletions Time-Wanderer/src/misc/SoundInterface.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package misc;

import java.util.logging.Level;
import java.util.logging.Logger;
import main.MainClass;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.geom.Vector2f;
import utils.NumberUtils;

Expand Down Expand Up @@ -88,7 +85,7 @@ public SoundInterface () {
}

/**
* Initialices the arrays with the images ({@code musicImages} and
* Initializes the arrays with the images ({@code musicImages} and
* {@code effectsImages})
*/
private void initImages () {
Expand All @@ -99,7 +96,7 @@ private void initImages () {
}

/**
* Inititalices the images array for the music icon.
* Initializes the images array for the music icon.
*/
private void initMusicImages () {

Expand Down Expand Up @@ -169,7 +166,7 @@ private void initMusicImages () {
}

/**
* Inititalices the images array for the music icon.
* Initializes the images array for the music icon.
*/
private void initEffectsImages () {

Expand Down
52 changes: 51 additions & 1 deletion Time-Wanderer/src/sound/Jukebox.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ public void play(Playlist sound, boolean finite) {
String path;
Playable p;

/* Checks if the sound can be played */
if (!check(sound)) {

return;
}

waitUntilClearIfStopped();

if (sound != null) {

switch (sound) {
Expand Down Expand Up @@ -198,6 +204,12 @@ public void play(Playlist sound, boolean finite) {
public void play(Playlist sound, boolean finite, float decibels) {
String path;
Playable p;

/* Checks if the sound can be played */
if (!check(sound)) {

return;
}

waitUntilClearIfStopped();

Expand Down Expand Up @@ -327,6 +339,12 @@ public void play(Playlist sound, boolean finite, float decibels) {
public void play(Playlist sound, int start, int end) {
String path;
Playable p;

/* Checks if the sound can be played */
if (!check(sound)) {

return;
}

waitUntilClearIfStopped();

Expand Down Expand Up @@ -458,6 +476,12 @@ public void play(Playlist sound, int start, int end) {
public void play(Playlist sound, int start, int end, float decibels) {
String path;
Playable p;

/* Checks if the sound can be played */
if (!check(sound)) {

return;
}

waitUntilClearIfStopped();

Expand Down Expand Up @@ -579,6 +603,32 @@ public void play(Playlist sound, int start, int end, float decibels) {
}

}

/**
* Checks if that sound can be played (depends on the attributes
* {@code musicON} and {@code effectsON}).
*/
private boolean check (Playlist sound) {

/* Checks if it's a music clip and can be played */
if (musicON && (
sound.equals(Playlist.GAME_OVER) ||
sound.equals(Playlist.GUITAR_CONCERT) ||
sound.equals(Playlist.MEMORIES) ||
sound.equals(Playlist.THE_LURKING_BEAST)
)) {

return true;
}

/* Checks if it's an effect clip and can be played */
return effectsON && !(
sound.equals(Playlist.GAME_OVER) &&
sound.equals(Playlist.GUITAR_CONCERT) &&
sound.equals(Playlist.MEMORIES) &&
sound.equals(Playlist.THE_LURKING_BEAST)
);
}

/**
* Awaits until the clips being played would terminate or until the time
Expand Down

0 comments on commit 6c95155

Please sign in to comment.