Skip to content

Commit

Permalink
Background music (Test 1)
Browse files Browse the repository at this point in the history
Modification of Sound.java to play background music (test 1)
  • Loading branch information
TheBigEye committed Nov 30, 2020
1 parent 1a8ff94 commit 89cd139
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/minicraft/core/io/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Sound {
public static final Sound back = new Sound("/resources/sound/craft.wav");
public static final Sound select = new Sound("/resources/sound/select.wav");
public static final Sound confirm = new Sound("/resources/sound/confirm.wav");
public static final Sound Intro = new Sound("/resources/sound/title/Intro.wav");

private Clip clip; // Creates a audio clip to be played

Expand Down Expand Up @@ -91,6 +92,7 @@ public void play() {
clip.start();
}


public void loop(boolean start) {
if (!(boolean)Settings.get("sound") || clip == null) return;

Expand All @@ -99,4 +101,9 @@ public void loop(boolean start) {
else
clip.stop();
}

public void stop() {
clip.stop();

}
}
4 changes: 4 additions & 0 deletions src/minicraft/screen/LoadingDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import minicraft.core.Game;
import minicraft.core.World;
import minicraft.core.io.Localization;
import minicraft.core.io.Sound;
import minicraft.gfx.Color;
import minicraft.gfx.Ellipsis;
import minicraft.gfx.Ellipsis.DotUpdater.TimeUpdater;
Expand Down Expand Up @@ -75,5 +76,8 @@ public void render(Screen screen) {
Localization.getLocalized(msg)+ ellipsis.updateAndGet(),
percent+"%"
);
{
Sound.Intro.stop();
}
}
}
11 changes: 10 additions & 1 deletion src/minicraft/screen/TitleDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import minicraft.core.VersionInfo;
import minicraft.core.World;
import minicraft.core.io.InputHandler;
import minicraft.core.io.Sound;
import minicraft.entity.mob.RemotePlayer;
import minicraft.gfx.Color;
import minicraft.gfx.Font;
Expand Down Expand Up @@ -70,6 +71,8 @@ public TitleDisplay() {
public void init(Display parent) {
super.init(null); // The TitleScreen never has a parent.
Renderer.readyToRenderGameplay = false;

Sound.Intro.loop(true);

// check version
checkVersion();
Expand Down Expand Up @@ -171,7 +174,11 @@ public void tick(InputHandler input) {
}

super.tick(input);
}


}



@Override
public void render(Screen screen) {
Expand All @@ -188,6 +195,8 @@ public void render(Screen screen) {
}
}



boolean isblue = splashes[rand].contains("blue");
boolean isGreen = splashes[rand].contains("Green");
boolean isRed = splashes[rand].contains("Red");
Expand Down
Binary file added src/resources/sound/title/Intro.wav
Binary file not shown.
Binary file modified src/resources/textures/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 89cd139

Please sign in to comment.