Load menu and level audio dynamically

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-15 14:54:57 +01:00
parent 6eb903cbaa
commit a75ade8b33
8 changed files with 67 additions and 6 deletions

View File

@@ -69,11 +69,15 @@ class _WolfRendererState extends State<WolfRenderer>
// Grab the specific level from the singleton
_currentLevel = Wolf3d.I.levels[mapIndex];
// Play the exact track id Software intended for this level!
Wolf3d.I.audio.playLevelMusic(_currentLevel);
// TODO: Initialize player position, spawn enemies based on difficulty, etc.
debugPrint("Loaded Level: ${_currentLevel.name}");
}
void _onLevelCompleted() {
Wolf3d.I.audio.stopMusic();
// When the player hits the elevator switch, advance the map
setState(() {
_currentMapIndex++;

View File

@@ -22,16 +22,13 @@ class _EpisodeScreenState extends State<EpisodeScreen> {
@override
void initState() {
super.initState();
if (Wolf3d.I.music.isNotEmpty) {
Wolf3d.I.audio.playMusic(Wolf3d.I.music.first);
}
Wolf3d.I.audio.playMenuMusic();
}
void _selectEpisode(int index) {
Wolf3d.I.setActiveEpisode(index);
Navigator.of(context).push(
MaterialPageRoute(
// We pass the audio handles so the next screen can stop them when the game starts
builder: (context) => DifficultyScreen(),
),
);
@@ -39,7 +36,6 @@ class _EpisodeScreenState extends State<EpisodeScreen> {
@override
Widget build(BuildContext context) {
// Determine how many episodes are available (10 levels per episode)
final int numberOfEpisodes = (Wolf3d.I.levels.length / 10).floor().clamp(
1,
6,

View File

@@ -45,6 +45,7 @@ class Wolf3d {
// --- Actions ---
void setActiveGame(WolfensteinData game) {
_activeGame = game;
audio.activeGame = game;
}
/// Initializes the engine by loading available game data.