From 897cb4a1402cf99998db1dc71aa90122c2132a1d Mon Sep 17 00:00:00 2001 From: bigJIU <1572204178@qq.com> Date: Wed, 1 Mar 2023 21:38:39 +0800 Subject: [PATCH] Add MarioInfo --- .../levels/{ => group0}/lvl65.lvl | 0 Mario-AI-Interface/reps/f_l_sav.rep | Bin 1009 -> 34 bytes Mario-AI-Interface/src/Play.java | 6 ++--- .../src/engine/core/MarioRender.java | 21 +++++++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) rename Mario-AI-Interface/levels/{ => group0}/lvl65.lvl (100%) diff --git a/Mario-AI-Interface/levels/lvl65.lvl b/Mario-AI-Interface/levels/group0/lvl65.lvl similarity index 100% rename from Mario-AI-Interface/levels/lvl65.lvl rename to Mario-AI-Interface/levels/group0/lvl65.lvl diff --git a/Mario-AI-Interface/reps/f_l_sav.rep b/Mario-AI-Interface/reps/f_l_sav.rep index e664b0ceec27f1278b667956370b82afd9d1dda2..5642265e8fb13f907e745102e62281ff49fc3dd0 100644 GIT binary patch literal 34 KcmZQzAOrvaA^-sZ literal 1009 ScmZQz7zLvtFd70QCIkQj@c;n; diff --git a/Mario-AI-Interface/src/Play.java b/Mario-AI-Interface/src/Play.java index dc0916d..1ffdb31 100644 --- a/Mario-AI-Interface/src/Play.java +++ b/Mario-AI-Interface/src/Play.java @@ -40,12 +40,12 @@ public class Play { public static byte[] playJavaGame(){ MarioGame game = new MarioGame(); - game.setLives(5); - String levelPath = "./levels/group0/f_l.txt"; // For local + game.setLives(20); + String levelPath = "./levels/group0/lvl1.lvl"; // For local String repPath = "./reps/f_l_sav.rep"; // For local //MarioGame.verbose = true; //Play Game - MarioResult tmpResult = game.playGame(new HumanAgent(false),getLevel(levelPath), 30, repPath,30); + MarioResult tmpResult = game.playGame(new HumanAgent(false),getLevel(levelPath), 1, repPath,30); //Replay //MarioResult tmpResult = game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), 30, repPath,30); return Replay.serializeAgentEvents(tmpResult.getAgentEvents()); diff --git a/Mario-AI-Interface/src/engine/core/MarioRender.java b/Mario-AI-Interface/src/engine/core/MarioRender.java index 8ca2fb2..d3bef9b 100644 --- a/Mario-AI-Interface/src/engine/core/MarioRender.java +++ b/Mario-AI-Interface/src/engine/core/MarioRender.java @@ -3,6 +3,7 @@ package engine.core; import javax.swing.*; import engine.helper.Assets; +import engine.helper.GameStatus; import engine.helper.MarioActions; import java.awt.*; @@ -56,8 +57,22 @@ public class MarioRender extends JComponent implements FocusListener { drawStringDropShadow(og, "Buttons: " + pressedButtons, 0, 2, 1); } //Render Status Info - drawString(og,"Game Over! ",11,3,1,0.5f); - drawString(og,"Game Over! ",11,5,1,0.5f); + + switch (world.gameStatus){ + case LOSE: + drawString(og,"Game Over! ",64,40,1,1.5f); + drawString(og,"YOU LOSE! ",66,56,1,1.5f); + break; + case TIME_OUT: + drawString(og,"Game Over! ",64,40,1,1.5f); + drawString(og,"Time OUT ",66,56,1,1.5f); + break; + case WIN: + drawString(og,"CONGRATULATION!",32,40,1,1.5f); + drawString(og,"YOU WIN!!",64,56,1,1.5f); + break; + } + if (scale > 1) { g.drawImage(image, 0, 0, (int) (256 * scale), (int) (240 * scale), null); @@ -69,7 +84,7 @@ public class MarioRender extends JComponent implements FocusListener { public void drawString(Graphics g, String text, int x, int y, int c,float scale){ char[] ch = text.toCharArray(); for (int i = 0; i < ch.length; i++) { - g.drawImage(Assets.font[ch[i] - 32][c], x + i * 8, y,(int) (256 * scale), (int) (240 * scale), null); + g.drawImage(Assets.font[ch[i] - 32][c], x + (int)(i * 8 * scale), y,(int) (8 * scale), (int) (8 * scale), null); } } public void drawStringDropShadow(Graphics g, String text, int x, int y, int c) {