This commit is contained in:
bigJIU 2023-03-07 20:07:40 +08:00
parent 257936c3c2
commit 551013c736
9 changed files with 29 additions and 32 deletions

11
.idea/workspace.xml generated
View File

@ -3,7 +3,12 @@
<component name="ChangeListManager">
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface.jar.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/Play.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/Play.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioGame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/helper/Assets.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/helper/Assets.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GamePlay.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GamePlay.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameTutorial.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameTutorial.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -228,7 +233,7 @@
<workItem from="1677595224096" duration="799000" />
<workItem from="1677674512203" duration="4789000" />
<workItem from="1677840429576" duration="1147000" />
<workItem from="1678093963205" duration="4472000" />
<workItem from="1678093963205" duration="6636000" />
</task>
<servers />
</component>
@ -250,6 +255,6 @@
<SUITE FILE_PATH="coverage/MarioWeb$MarioWeb.coverage" NAME="MarioWeb Coverage Results" MODIFIED="1669305478201" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
<SUITE FILE_PATH="coverage/MarioWeb$test.coverage" NAME="test Coverage Results" MODIFIED="1668079935841" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1677224605926" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py___1_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1678188177267" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py___1_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1678190392807" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -26,13 +26,16 @@ public class Play {
//FIXME: Debug Use
//playGameMain("lvl1");
initialGame();
playJavaGame();
// initialGame();
// playJavaGame();
System.out.println("Java: Play Java Main Function Done");
}
public static boolean initialGame(){
game = new MarioGame();
game.renderGame();
String levelName = "t1";
String levelPath = String.format("/app/levels/%s.lvl", levelName); // For web
String repPath = String.format("/files/%s_sav.rep", levelName); // For web
game.playGame(new HumanAgent(true),getLevel(levelPath),0,repPath,10);
return true;
}

View File

@ -115,17 +115,6 @@ public class MarioGame extends KeyAdapter{
return this.runGame(agent, level, timer, 0, true, 50, 2, "",col);
}
public boolean renderGame(){
this.window = new JFrame("Mario AI Framework");
this.render = new MarioRender(2);
this.window.setContentPane(this.render);
this.window.pack();
this.window.setResizable(false);
this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.render.init();
this.window.setVisible(true);
return true;
}
/**
* Run a certain mario level with a certain agent
@ -140,7 +129,7 @@ public class MarioGame extends KeyAdapter{
* @return statistics about the current game
*/
public MarioResult runGame(MarioAgent agent, String level, int timer, int marioState, boolean visuals, int fps, float scale, String resultPath, int col) {
/* if (visuals) {
if (visuals) {
this.window = new JFrame("Mario AI Framework");
this.render = new MarioRender(scale);
this.window.setContentPane(this.render);
@ -149,7 +138,7 @@ public class MarioGame extends KeyAdapter{
this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.render.init();
this.window.setVisible(true);
}*/
}
this.setAgent(agent);
return this.gameLoop(level, timer, marioState, visuals, fps, resultPath, col);
}

View File

@ -43,8 +43,8 @@ public class Assets {
private static Image getImage(GraphicsConfiguration gc, String imageName) throws IOException {
//FIXME: web/local
File file = new File(System.getProperty("user.dir") + "/img/" + imageName); // Local test
//File file = new File("/app/img/" + imageName); // For web
//File file = new File(System.getProperty("user.dir") + "/img/" + imageName); // Local test
File file = new File("/app/img/" + imageName); // For web
BufferedImage source = ImageIO.read(file);
Image image = gc.createCompatibleImage(source.getWidth(), source.getHeight(), Transparency.BITMASK);
Graphics2D g = (Graphics2D) image.getGraphics();

Binary file not shown.

View File

@ -214,7 +214,7 @@
GameLoad().then(function () {
console.log("GameLoad Initialize Succeed!");
document.getElementById("loading").style.visibility = 'hidden';
}).then(function (){
})
for (i = 0; i < levelNum - 1; i++) {
@ -233,7 +233,7 @@
alert("Please proceed to answer some questions about the levels you just played!")
window.location.href = "{{jump}}"
});
})

View File

@ -243,7 +243,7 @@
console.log("Cheerpj Initialize Succeed!");
document.getElementById("loading").style.visibility = "hidden";
}).then(function (){
})
var control = ("{{control}}" == "1");
PlayLevel(level,control)
@ -256,7 +256,7 @@
});
})
' class="cirButton">
<h3>Repeat Tutorial</h3>
@ -312,7 +312,7 @@
GameLoad().then(function () {
console.log("Cheerpj Initialize Succeed!");
$("#windowshow: visible").hide();
$("#windowshow:visible").hide();
$("#countdown").hide();
document.getElementById("loading").style.visibility = 'hidden';
})