diff --git a/assets/sounds/effects/door_close.mp3 b/assets/sounds/effects/door_close.mp3 new file mode 100644 index 0000000..841ee64 Binary files /dev/null and b/assets/sounds/effects/door_close.mp3 differ diff --git a/assets/sounds/effects/door_open.mp3 b/assets/sounds/effects/door_open.mp3 new file mode 100644 index 0000000..5460e6d Binary files /dev/null and b/assets/sounds/effects/door_open.mp3 differ diff --git a/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt b/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt index 51b58dd..424ce22 100644 --- a/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt +++ b/core/src/main/kotlin/com/last/commit/audio/GameSoundEffect.kt @@ -4,6 +4,8 @@ import com.last.commit.audio.GameSound public class GameSoundEffect(name: String): GameSound(name) { companion object { - val STEPS_INDOOR = GameSoundEffect("steps_indoor.mp3"); + val STEPS_INDOOR = GameSoundEffect("steps_indoor.mp3") + val DOOR_OPEN = GameSoundEffect("door_open.mp3") + val DOOR_CLOSE = GameSoundEffect("door_close.mp3") } } \ No newline at end of file diff --git a/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt b/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt index e7e025c..cb674d0 100644 --- a/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt +++ b/core/src/main/kotlin/com/last/commit/audio/SoundEngine.kt @@ -19,7 +19,6 @@ public class SoundEngine { println("Playing sound ${gameSound.name}") } else if (gameSound is GameMusic) { val music = loadMusic(gameSound.name) - music.stop() music.volume = volume music.setLooping(true) music.play() diff --git a/core/src/main/kotlin/com/last/commit/map/Door.kt b/core/src/main/kotlin/com/last/commit/map/Door.kt index 2a9df91..450b094 100644 --- a/core/src/main/kotlin/com/last/commit/map/Door.kt +++ b/core/src/main/kotlin/com/last/commit/map/Door.kt @@ -4,6 +4,7 @@ import GameState import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell import com.badlogic.gdx.math.Rectangle import com.last.commit.Wall +import com.last.commit.audio.GameSoundEffect class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) : Wall(gridX, gridY, wallCollider, cell), Interactable { @@ -11,11 +12,13 @@ class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) : override fun interact(otherCollider: Rectangle, state: GameState) { println("interacting with door $this") if (isClosed) { + state.soundEngine.play(GameSoundEffect.DOOR_OPEN) isOpen = true } else if (isOpen) { if (getCollider().overlaps(otherCollider)) { // can't close the door cause it is colliding with given collider } else { + state.soundEngine.play(GameSoundEffect.DOOR_CLOSE) isOpen = false } } diff --git a/core/src/main/kotlin/com/last/commit/screen/FirstScreen.kt b/core/src/main/kotlin/com/last/commit/screen/FirstScreen.kt index 52ba93e..ec6e29c 100644 --- a/core/src/main/kotlin/com/last/commit/screen/FirstScreen.kt +++ b/core/src/main/kotlin/com/last/commit/screen/FirstScreen.kt @@ -62,7 +62,7 @@ class FirstScreen(val gameState: GameState) : Screen, InputProcessor { shapeRenderer.setAutoShapeType(true) Gdx.input.setInputProcessor(this) - gameState.soundEngine.play(GameMusic.WORLD_MUSIC, 0.5f) + gameState.soundEngine.play(GameMusic.WORLD_MUSIC, 0.25f) } fun loadGameConfig(): GameConfig {