Skip to content

Commit

Permalink
added music to the main game
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj42 committed Apr 17, 2018
1 parent 0b66080 commit cd29d70
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/client/src/miniventure/game/client/GameClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import miniventure.game.screen.ErrorScreen;
import miniventure.game.screen.MainMenu;
import miniventure.game.screen.MenuScreen;
import miniventure.game.util.MyUtils;
import miniventure.game.util.ProgressLogger;
import miniventure.game.world.Chunk;
import miniventure.game.world.Chunk.ChunkData;
Expand All @@ -27,6 +28,8 @@
import miniventure.game.world.tile.ClientTile;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.esotericsoftware.kryonet.Client;
import com.esotericsoftware.kryonet.Connection;
Expand Down Expand Up @@ -69,6 +72,12 @@ public void received (Connection connection, Object object) {
SpawnData data = (SpawnData) object;
world.spawnPlayer(data);
ClientCore.setScreen(null);
Music song = ClientCore.setMusicTrack(Gdx.files.internal("audio/music/game.mp3"));
song.setOnCompletionListener(music -> {
music.stop();
MyUtils.delay(MathUtils.random(10_000, 30_000), music::play);
});
MyUtils.delay(1_000, song::play);
}

if(object instanceof TileUpdate) {
Expand Down
2 changes: 1 addition & 1 deletion core/client/src/miniventure/game/screen/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void clicked(InputEvent e, float x, float y) {
music.stop();
music.play();
}));*/
song.setVolume(0.5f);
//song.setVolume(0.5f);
//MyUtils.delay(100, song::play);
song.setLooping(true);
song.play();
Expand Down
Binary file added core/game/assets/audio/music/game.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions notes/to-do.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ level system; note that levels will not solely be identified by depth (though th

****

make some mobs hurt you, once I get more mob sprites.

****

0 comments on commit cd29d70

Please sign in to comment.