Skip to content
Snippets Groups Projects
Commit 9b6b929c authored by Gehrung Jonas's avatar Gehrung Jonas
Browse files

UPDATE: soundeffects

parent fde38fce
No related branches found
Tags v0.4.5
3 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development
......@@ -101,6 +101,8 @@ public class GameSceneController implements Initializable {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
runtimeInfo.setGameState(GameState.PLAYING);
AnimationTimer gameLoop = new AnimationTimer() {
......
......@@ -19,6 +19,9 @@ import java.util.ArrayList;
import java.util.Objects;
import java.util.ResourceBundle;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class MapSelectionController implements Initializable {
@FXML
private VBox boxBox, parent;
......@@ -31,6 +34,8 @@ public class MapSelectionController implements Initializable {
private final ArrayList<MapData> coreMaps = Persistence.getInstance().getCoreMaps();
private static Logger log = LogManager.getLogger(MapSelectionController.class);
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
ToggleGroup group = new ToggleGroup();
......@@ -60,6 +65,7 @@ public class MapSelectionController implements Initializable {
MusicPlayerSingleton.getInstance().getMediaPlayer().dispose();
parent.getScene().setRoot(FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameScene.fxml"))));
} catch (IOException e) {
log.info(e.getCause());
throw new RuntimeException();
}
}
......
......@@ -20,22 +20,20 @@ import java.util.ResourceBundle;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class MusicPlayer implements Initializable {
public class MusicPlayer {
private static final Logger log = LogManager.getLogger(MusicPlayer.class);
private MediaPlayer mediaPlayer;
private RuntimeInfo runtimeInfo;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
setVolume(runtimeInfo.getMusicVolume());
}
//Runtime
//Todo Make music play
public void playGameMusic(MusicType musicType) throws IOException {
Path pathTypeOfMusic = Paths.get(musicType.getPath());
List<Path> musicPaths = getFilePathsFromResources(pathTypeOfMusic);
String randomPath = getRandomFilePath(musicPaths);
String resource = convertPathToResourcePath(randomPath);
setVolume(runtimeInfo.getMusicVolume());
playMusicLoop(resource);
}
......
......@@ -18,23 +18,23 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.ResourceBundle;
public class SoundEffects implements Initializable {
public class SoundEffects {
private static final Logger log = LogManager.getLogger(SoundEffects.class);
private int sfxVolume;
private RuntimeInfo runtimeInfo;
GameSceneController gameSceneController;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
sfxVolume = runtimeInfo.getSfxVolume();
}
public void playSoundEffect() throws IOException, InterruptedException {
GameSceneController gameSceneController = new GameSceneController();
MusicPlayer musicPlayer = new MusicPlayer();
InputHandler inputhandler = InputHandler.getInstance();
TileManager tileManager = gameSceneController.getTileManager();
IEntity player = gameSceneController.getPlayer();
TileManager tileManager = gameSceneController.getTileManager();// TODO Find out why tileManager is null
log.info(tileManager);
/*IEntity player = gameSceneController.getPlayer();
ITile[] tileSet = tileManager.getTileSet();
int[][] map = tileManager.getTileMap();
int playerPosX;
......@@ -54,6 +54,7 @@ public class SoundEffects implements Initializable {
String resource = musicPlayer.convertPathToResourcePath(randomPath);
Thread sfxLoop = new Thread(() -> {
AudioClip effect = new AudioClip(resource);
effect.setVolume(runtimeInfo.getSfxVolume());
effect.setVolume((double) sfxVolume / 100); //TODO Replace with own Method
effect.play();
});
......@@ -63,7 +64,7 @@ public class SoundEffects implements Initializable {
sfxPaths.clear();
}
}
*/
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment