Skip to content

Commit 36deeba

Browse files
committed
#22 Sophisticated shuffle
Fixed input issues Reworked fields in Entities, Mobs, etc.
1 parent cc0858a commit 36deeba

38 files changed

+688
-2026
lines changed

src/com/redomar/game/Game.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
import com.redomar.game.entities.Player;
66
import com.redomar.game.entities.Vendor;
77
import com.redomar.game.entities.trees.Spruce;
8+
import com.redomar.game.event.InputHandler;
9+
import com.redomar.game.event.MouseHandler;
810
import com.redomar.game.gfx.Screen;
911
import com.redomar.game.gfx.SpriteSheet;
1012
import com.redomar.game.level.LevelHandler;
13+
import com.redomar.game.lib.Either;
1114
import com.redomar.game.lib.Font;
1215
import com.redomar.game.lib.Time;
13-
import com.redomar.game.script.PrintTypes;
14-
import com.redomar.game.script.Printer;
16+
import com.redomar.game.log.PrintTypes;
17+
import com.redomar.game.log.Printer;
1518
import org.apache.commons.text.WordUtils;
1619

1720
import javax.swing.*;
@@ -68,10 +71,10 @@ public class Game extends Canvas implements Runnable {
6871
private final BufferedImage image2 = new BufferedImage(WIDTH, HEIGHT - 30, BufferedImage.TYPE_INT_RGB);
6972
private final Font font = new Font(); // Font object capable of displaying 2 fonts: Arial and Segoe UI
7073
private final Printer printer = new Printer();
74+
boolean musicPlaying = false;
7175
private int tickCount = 0;
7276
private Screen screen;
7377
private LevelHandler level; // Loads and renders levels along with tiles, entities, projectiles and more.
74-
7578
//The entities of the game
7679
private Player player;
7780
private Dummy dummy; // Dummy NPC follows the player around
@@ -385,9 +388,17 @@ public void run() {
385388
*/
386389
public void tick() {
387390
setTickCount(getTickCount() + 1);
391+
Either<Exception, Boolean> musicKeyAction = input.toggleActionWithCheckedRunnable(input.getM_KEY(), musicPlaying, () -> Game.getBackgroundMusic().play(), () -> Game.getBackgroundMusic().stop());
392+
musicKeyAction.either(exception -> {
393+
printer.cast().print("Failed to play music", PrintTypes.MUSIC);
394+
printer.exception(exception.toString());
395+
musicPlaying = false;
396+
}, isPlaying -> musicPlaying = isPlaying);
397+
388398
level.tick();
389399
}
390400

401+
391402
/**
392403
* This method displays the current state of the game.
393404
*/

src/com/redomar/game/InputHandler.java

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)