Fixes sounds
All checks were successful
EpicKnarvik97/Rogue101/master This commit looks good

This commit is contained in:
Kristian Knarvik 2020-02-14 20:29:42 +01:00
parent 422542fe82
commit de0924845d
2 changed files with 13 additions and 17 deletions

View File

@ -473,18 +473,15 @@ public class Game implements IGame {
@Override
public IItem createItem(String sym) {
switch (sym) {
case " ":
if (" ".equals(sym)) {
return null;
}// alternative/advanced method
Supplier<IItem> factory = itemFactories.get(sym);
if (factory != null) {
return factory.get();
} else {
System.err.println("createItem: Don't know how to create a '" + sym + "'");
return null;
default:
// alternative/advanced method
Supplier<IItem> factory = itemFactories.get(sym);
if (factory != null) {
return factory.get();
} else {
System.err.println("createItem: Don't know how to create a '" + sym + "'");
return null;
}
}
}
@ -538,14 +535,14 @@ public class Game implements IGame {
if (lastMessages.size() > 2 && !thirdLineWritten) {
printer.printAt(1, Main.LINE_MSG3, lastMessages.get(2));
}
System.out.println("Message: «" + s + "»");
//System.out.println("Message: «" + s + "»");
}
@Override
public void displayStatus(String s) {
printer.clearLine(Main.LINE_STATUS);
printer.printAt(1, Main.LINE_STATUS, s);
System.out.println("Status: «" + s + "»");
//System.out.println("Status: «" + s + "»");
}
public void draw() {

View File

@ -10,6 +10,7 @@ import inf101.v18.rogue101.objects.IActor;
import inf101.v18.rogue101.objects.IItem;
import inf101.v18.rogue101.objects.IPlayer;
import inf101.v18.rogue101.states.Attack;
import javafx.scene.media.AudioClip;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
@ -171,10 +172,8 @@ public class NPC {
public static void playSound(String filename) {
URL url = NPC.class.getClassLoader().getResource(filename);
if (url != null) {
System.out.println("Playing " + url.toString());
Media sound = new Media(url.toString());
MediaPlayer mediaPlayer = new MediaPlayer(sound);
mediaPlayer.play();
AudioClip clip = new AudioClip(url.toString());
clip.play();
} else {
System.out.println("Could not play audio file " + filename);
}