Merge remote-tracking branch 'origin/main' into main

imgbot
MehdiAyadi 2 years ago
commit 541428b658

@ -4,6 +4,8 @@ import com.last.commit.audio.GameSound
public class GameSoundEffect(name: String): GameSound(name) { public class GameSoundEffect(name: String): GameSound(name) {
companion object { 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")
} }
} }

@ -19,7 +19,6 @@ public class SoundEngine {
println("Playing sound ${gameSound.name}") println("Playing sound ${gameSound.name}")
} else if (gameSound is GameMusic) { } else if (gameSound is GameMusic) {
val music = loadMusic(gameSound.name) val music = loadMusic(gameSound.name)
music.stop()
music.volume = volume music.volume = volume
music.setLooping(true) music.setLooping(true)
music.play() music.play()

@ -4,6 +4,7 @@ import GameState
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell
import com.badlogic.gdx.math.Rectangle import com.badlogic.gdx.math.Rectangle
import com.last.commit.Wall import com.last.commit.Wall
import com.last.commit.audio.GameSoundEffect
class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) : class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) :
Wall(gridX, gridY, wallCollider, cell), Interactable { 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) { override fun interact(otherCollider: Rectangle, state: GameState) {
println("interacting with door $this") println("interacting with door $this")
if (isClosed) { if (isClosed) {
state.soundEngine.play(GameSoundEffect.DOOR_OPEN)
isOpen = true isOpen = true
} else if (isOpen) { } else if (isOpen) {
if (getCollider().overlaps(otherCollider)) { if (getCollider().overlaps(otherCollider)) {
// can't close the door cause it is colliding with given collider // can't close the door cause it is colliding with given collider
} else { } else {
state.soundEngine.play(GameSoundEffect.DOOR_CLOSE)
isOpen = false isOpen = false
} }
} }

@ -62,7 +62,7 @@ class FirstScreen(val gameState: GameState) : Screen, InputProcessor {
shapeRenderer.setAutoShapeType(true) shapeRenderer.setAutoShapeType(true)
Gdx.input.setInputProcessor(this) Gdx.input.setInputProcessor(this)
gameState.soundEngine.play(GameMusic.WORLD_MUSIC, 0.5f) gameState.soundEngine.play(GameMusic.WORLD_MUSIC, 0.25f)
} }
fun loadGameConfig(): GameConfig { fun loadGameConfig(): GameConfig {

Loading…
Cancel
Save