Update Loading Screen, Fast Loading speed
This commit is contained in:
parent
b5ca526f8b
commit
da6f5af372
22
.idea/workspace.xml
generated
22
.idea/workspace.xml
generated
@ -5,12 +5,17 @@
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/agents/HumanAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/HumanAgent.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/ReplayAgent.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/agents/ReplayAgent.java" 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/core/MarioWorld.java" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/src/engine/core/MarioWorld.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data/annotation.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/annotation.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data/questionare.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/templates/GameWelcome.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameWelcome.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation2.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation2.html" 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" />
|
||||
<change beforePath="$PROJECT_DIR$/templates/data.js" beforeDir="false" afterPath="$PROJECT_DIR$/templates/data.js" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -65,7 +70,7 @@
|
||||
<recent name="C:\Users\duaho\Projects\website materials\MarioWeb\img" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Flask server.Flask (main.py)">
|
||||
<component name="RunManager" selected="Flask server.Flask (main.py) (1)">
|
||||
<configuration name="MarioWeb" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="MarioWeb" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@ -164,8 +169,8 @@
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Flask server.Flask (main.py)" />
|
||||
<item itemvalue="Flask server.Flask (main.py) (1)" />
|
||||
<item itemvalue="Flask server.Flask (main.py)" />
|
||||
<item itemvalue="Python.test" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
@ -212,7 +217,8 @@
|
||||
<workItem from="1675829047440" duration="2956000" />
|
||||
<workItem from="1676377283551" duration="34000" />
|
||||
<workItem from="1676991343098" duration="1013000" />
|
||||
<workItem from="1677221941122" duration="1304000" />
|
||||
<workItem from="1677221941122" duration="2329000" />
|
||||
<workItem from="1677303698061" duration="6278000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -233,7 +239,7 @@
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<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="1677223621991" 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) (1) Coverage Results" MODIFIED="1668079945407" 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$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) (1) Coverage Results" MODIFIED="1677309921250" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -22,8 +22,7 @@ public class Play {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String groupID = args[0];
|
||||
String levelName = args[1];
|
||||
|
||||
//MarioGame game = new MarioGame();
|
||||
|
||||
// String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For web
|
||||
@ -38,6 +37,15 @@ public class Play {
|
||||
//FIXME: Debug Use
|
||||
//playGameMain("lvl1");
|
||||
|
||||
System.out.println("Java: Play Java Main Function Done");
|
||||
}
|
||||
public static boolean initialGame(){
|
||||
game = new MarioGame();
|
||||
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;
|
||||
}
|
||||
|
||||
public static byte[] playGameMain(String levelName, int lives, boolean control,int time,int col){
|
||||
@ -47,8 +55,7 @@ public class Play {
|
||||
|
||||
// String levelPath = String.format("./levels/group%s/%s.lvl", "0", levelName); // For local
|
||||
// String repPath = String.format("./reps/%s_sav.rep", levelName); // For local
|
||||
game = new MarioGame();
|
||||
game.setLives(lives);
|
||||
game.setLives(lives);
|
||||
MarioResult tmpResult = game.playGame(new HumanAgent(control),getLevel(levelPath), time, repPath,col);
|
||||
|
||||
return Replay.serializeAgentEvents(tmpResult.getAgentEvents());
|
||||
@ -64,8 +71,7 @@ public class Play {
|
||||
|
||||
// String levelPath = String.format("/app/levels/group%s/%s.txt", groupID, levelName); // For local
|
||||
// String repPath = String.format("./files/%s_sav.rep", levelName); // For local
|
||||
|
||||
game = new MarioGame();
|
||||
|
||||
game.setLives(lives);
|
||||
return game.playGame(Replay.getRepAgentFromFile(repPath),getLevel(levelPath), time, repPath,col);
|
||||
}
|
||||
|
@ -192,6 +192,10 @@ public class MarioGame extends KeyAdapter{
|
||||
+ Math.abs(agentTimer.getRemainingTime()) + " msec.");
|
||||
}
|
||||
}
|
||||
if(timer==0){
|
||||
this.world.lose();
|
||||
replayBreak = true;
|
||||
}
|
||||
// Mid Break & Cheat Mode
|
||||
if(actions[0]&&actions[1]){
|
||||
this.world.lose();
|
||||
@ -234,7 +238,7 @@ public class MarioGame extends KeyAdapter{
|
||||
}
|
||||
|
||||
public void stopGame(){
|
||||
this.world.gameStatus = GameStatus.LOSE;
|
||||
this.world.lose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,6 +216,8 @@ public class MarioWorld {
|
||||
}
|
||||
|
||||
public void timeout() {
|
||||
System.out.println("Java: Time out");
|
||||
this.addEvent(EventType.LOSE, 0);
|
||||
this.gameStatus = GameStatus.TIME_OUT;
|
||||
this.mario.alive = false;
|
||||
}
|
||||
|
Binary file not shown.
@ -26,3 +26,4 @@ IP,A-ID,B-ID,Anno,
|
||||
127.0.0.1,160,84,N,
|
||||
127.0.0.1,75,17,N,
|
||||
127.0.0.1,69,73,N,
|
||||
127.0.0.1,31,125,N,
|
||||
|
|
@ -176,3 +176,22 @@ IP,Style,Frequency,Age,Gender
|
||||
127.0.0.1,A,A,D,A,D,A,,
|
||||
127.0.0.1,A,A,D,A,A,A,,
|
||||
127.0.0.1,A,A,A,E,A,C,,
|
||||
127.0.0.1,A,A,A,A,A,A,,
|
||||
127.0.0.1,A,A,A,A,A,A,,
|
||||
127.0.0.1,A,A,A,B,A,A,,
|
||||
127.0.0.1,A,A,A,D,G,A,,
|
||||
127.0.0.1,A,A,A,C,C,B,,
|
||||
127.0.0.1,A,A,A,A,A,A,,
|
||||
127.0.0.1,C,A,A,A,A,A,,
|
||||
127.0.0.1,A,A,A,B,C,A,,
|
||||
127.0.0.1,A,A,A,E,A,B,,
|
||||
127.0.0.1,A,A,A,A,A,A,,
|
||||
127.0.0.1,A,A,D,B,G,A,,
|
||||
127.0.0.1,C,A,A,A,A,A,,
|
||||
127.0.0.1,A,A,A,C,A,A,,
|
||||
127.0.0.1,C,A,A,E,A,A,,
|
||||
127.0.0.1,A,A,A,A,A,A,,
|
||||
127.0.0.1,C,A,A,C,A,A,,
|
||||
127.0.0.1,C,A,D,B,E,A,,
|
||||
127.0.0.1,C,A,A,A,G,A,,
|
||||
127.0.0.1,C,A,B,B,A,A,,
|
||||
|
|
11
main.py
11
main.py
@ -19,6 +19,7 @@ annotationPath2 = "data/annotation2.csv"
|
||||
|
||||
@app.route('/')
|
||||
def gamewelcome():
|
||||
#return redirect(url_for('gameplay', id=request.remote_addr))
|
||||
return render_template('GameWelcome.html')
|
||||
|
||||
@app.route('/question')
|
||||
@ -33,7 +34,13 @@ def gamepreplay():
|
||||
ip = request.remote_addr
|
||||
# Save the result to questionare
|
||||
idm.write_csv(questionarePath,
|
||||
[ip,result.get("playeds"),result.get("playedp"), result.get("gamestyle"), result.get("frequency"), result.get("age"), result.get("gender"),
|
||||
[ip,
|
||||
result.get("playeds"),
|
||||
result.get("playedp"),
|
||||
result.get("gamestyle"),
|
||||
result.get("frequency"),
|
||||
result.get("age"),
|
||||
result.get("gender"),
|
||||
""])
|
||||
idm.setControl(ip, result.get("control"))
|
||||
print(result.get("gamestyle"))
|
||||
@ -64,6 +71,7 @@ def gameplay(id):
|
||||
jump="/annotation")
|
||||
|
||||
|
||||
|
||||
@app.route('/gameplay/<id>/data', methods=['POST'])
|
||||
def getJSONData(id):
|
||||
if request.method == 'POST':
|
||||
@ -79,6 +87,7 @@ def gamepreanno():
|
||||
return redirect(url_for('gameanno', id=request.remote_addr))
|
||||
|
||||
|
||||
|
||||
@app.route('/annotation/<id>')
|
||||
def gameanno(id):
|
||||
if (id != "radioresult"):
|
||||
|
@ -2,6 +2,8 @@
|
||||
<!-- saved from url=(0029)http://aingames.cn/index.html -->
|
||||
<html lang="en"><script id="allow-copy_script">(function t(){var t=!1;document.addEventListener("allow_copy",(function(n){t=n.detail.unlock}));var n=["copy","cut","contextmenu","selectstart","mousedown","mouseup","mousemove","keydown","keypress","keyup"],e=function(n){t&&(n.stopPropagation(),n.stopImmediatePropagation&&n.stopImmediatePropagation())};n.forEach((function(t){document.documentElement.addEventListener(t,e,{capture:!0})}))})()</script><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
|
||||
|
||||
<script src="../templates/data.js"></script>
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@ -242,6 +244,7 @@ function Replay(id){
|
||||
var divElement = document.getElementById("replayWindowGame");
|
||||
cheerpjCreateDisplay(500,500,divElement);
|
||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||
GameLoad().then(function (){})
|
||||
closeReplayWindow();
|
||||
</script>
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
|
||||
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.10.2/Sortable.min.js"></script>
|
||||
|
||||
<script src="../templates/data.js"></script>
|
||||
</script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@ -195,6 +197,7 @@ function Replay(id){
|
||||
var divElement = document.getElementById("replayWindowGame");
|
||||
cheerpjCreateDisplay(500,500,divElement);
|
||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||
GameLoad()
|
||||
closeReplayWindow();
|
||||
</script>
|
||||
|
||||
|
@ -59,6 +59,37 @@
|
||||
width: 50px;
|
||||
height: 26px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
.loading-container {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 60px;
|
||||
height: 80px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.loader {
|
||||
position: absolute;
|
||||
|
||||
border: 8px solid #f3f3f3;
|
||||
border-top: 8px solid #3498db;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
animation: spin 2s linear infinite;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -98,11 +129,7 @@
|
||||
<section id="news">
|
||||
|
||||
<div class="container">
|
||||
{# <div class="page-header">#}
|
||||
{# <h1>#}
|
||||
{# <i class="fa-solid fa-gamepad"><b>EDRL Game Demo</b></i>#}
|
||||
{# </h1>#}
|
||||
{# </div>#}
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
@ -113,7 +140,10 @@
|
||||
<h3 id="Head">Level A</h3>
|
||||
</div>
|
||||
<div align="center" id = "GameWindow">
|
||||
|
||||
<div class="loading-container" id = "loading" style="visibility: visible">
|
||||
<div class="loader"></div>
|
||||
<div class="loading-text">Loading</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@ -129,8 +159,14 @@
|
||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||
console.log("Cheerpj Initialize Succeed!");
|
||||
console.log("Going to play %d levels under control %s",levelNum,"{{control}}")
|
||||
var control = ("HTML: {{control}}" == "1");
|
||||
|
||||
GameLoad().then(function (){
|
||||
console.log("Cheerpj Initialize Succeed!");
|
||||
document.getElementById("loading").style.visibility = 'hidden';
|
||||
})
|
||||
|
||||
|
||||
var control = ("{{control}}" == "1");
|
||||
for (i = 0; i < levelNum-1; i++) {
|
||||
console.log("Play level: %s",levels[i])
|
||||
PlayLevel(levels[i],control)
|
||||
|
@ -79,6 +79,39 @@
|
||||
height: 26px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
.loading-container {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 60px;
|
||||
height: 80px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
}
|
||||
|
||||
.loader {
|
||||
position: absolute;
|
||||
|
||||
border: 8px solid #f3f3f3;
|
||||
border-top: 8px solid #3498db;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
animation: spin 2s linear infinite;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@ -117,11 +150,6 @@
|
||||
<section id="news">
|
||||
|
||||
<div class="container">
|
||||
{# <div class="page-header">#}
|
||||
{# <h1>#}
|
||||
{# <i class="fa-solid fa-gamepad"><b>EDRL Game Demo</b></i>#}
|
||||
{# </h1>#}
|
||||
{# </div>#}
|
||||
<br>
|
||||
|
||||
<div class="row clearfix">
|
||||
@ -139,7 +167,11 @@
|
||||
|
||||
</div>
|
||||
<div align="center" id = "GameWindow">
|
||||
|
||||
<div class="loading-container" id="loading" style="visibility: visible">
|
||||
<div class="loader"></div>
|
||||
<div class="loading-text">Loading</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -165,19 +197,23 @@
|
||||
|
||||
cheerpjCreateDisplay(500,500,divElement);
|
||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||
console.log("Cheerpj Initialize Succeed!");
|
||||
|
||||
GameLoad().then(function(){
|
||||
console.log("Cheerpj Initialize Succeed!");
|
||||
document.getElementById("loading").style.visibility = 'hidden';
|
||||
})
|
||||
|
||||
var control = ("{{control}}" == "1");
|
||||
PlayLevel(level,control)
|
||||
|
||||
PlayLevel(level,control)
|
||||
.then(function (){
|
||||
//play next?
|
||||
if ("{{next}}"=="1"){
|
||||
document.getElementById("next").style.visibility = "visible";
|
||||
}
|
||||
document.getElementById("game").style.visibility = "visible";
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
@ -29,8 +29,11 @@ function PostToServer(url,data) {
|
||||
$.post(url, data);
|
||||
}
|
||||
}
|
||||
function GameLoad(){
|
||||
return cjCall("Play","initialGame");
|
||||
}
|
||||
function PlayLevel(level,control){
|
||||
|
||||
console.log("HTML:Start PlayLevel cjCall")
|
||||
var returnVal = cjCall("Play", "playGameMain", level, 5, control,30,16);
|
||||
return returnVal.then(function(){
|
||||
console.log("the return val is ready");
|
||||
|
Loading…
Reference in New Issue
Block a user