Add time travel sound

viewport-stuff
trivernis 2 years ago
parent 810e07cc44
commit 0404964b84
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -13,5 +13,6 @@ public class GameSoundEffect(name: String): GameSound(name) {
val DOOR_OPEN = GameSoundEffect("door_open.mp3") val DOOR_OPEN = GameSoundEffect("door_open.mp3")
val DOOR_CLOSE = GameSoundEffect("door_close.mp3") val DOOR_CLOSE = GameSoundEffect("door_close.mp3")
val TIME_TRAVEL = GameSoundEffect("time_travel.mp3")
} }
} }

@ -14,6 +14,7 @@ import com.badlogic.gdx.utils.Array
import com.last.commit.Collidable import com.last.commit.Collidable
import com.last.commit.Player import com.last.commit.Player
import com.last.commit.Wall import com.last.commit.Wall
import com.last.commit.audio.GameSoundEffect
import Position import Position
import GameState import GameState
@ -50,6 +51,7 @@ class TimeMap(fileName: String, val state: GameState) {
for (teleporter in teleporters) { for (teleporter in teleporters) {
if (teleporter is RectangleMapObject) { if (teleporter is RectangleMapObject) {
if (teleporter.rectangle.contains(player.getX(), player.getY())) { if (teleporter.rectangle.contains(player.getX(), player.getY())) {
state.soundEngine.play(GameSoundEffect.TIME_TRAVEL)
val targetMap = teleporter.properties.get("target", String::class.java) val targetMap = teleporter.properties.get("target", String::class.java)
System.out.println("Teleporting to targetMap $targetMap") System.out.println("Teleporting to targetMap $targetMap")
map = mapLoader.load("tiled/$targetMap") map = mapLoader.load("tiled/$targetMap")
@ -67,6 +69,7 @@ class TimeMap(fileName: String, val state: GameState) {
fun getPlayerSpawn(): Vector2 { fun getPlayerSpawn(): Vector2 {
val mapLayers = map.layers val mapLayers = map.layers
val spawnPoints = mapLayers["Spawnpoints"].objects val spawnPoints = mapLayers["Spawnpoints"].objects
for (spawnPoint in spawnPoints) { for (spawnPoint in spawnPoints) {
val spawnPointProperties = spawnPoint.properties val spawnPointProperties = spawnPoint.properties
if (spawnPointProperties != null && spawnPointProperties.containsKey("playerSpawn")) { if (spawnPointProperties != null && spawnPointProperties.containsKey("playerSpawn")) {

Loading…
Cancel
Save