MarioWeb/play.html
2022-10-20 22:48:14 +08:00

46 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CheerpJ test</title>
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
<script src="https://cdn.bootcss.com/FileSaver.js/1.3.8/FileSaver.js"></script>
</head>
<body>
</body>
<br />{{ py2htmlstr }}
<script>
function showPreloadProgress(loadedFiles, totalFiles)
{
console.log("Percentage loaded "+(loadedFiles*100/totalFiles));
}
function saveHandler(){
let data = {
name:"hanmeimei",
age:88
}
var content = JSON.stringify(data);
var blob = new Blob([content], {type: "text/plain;charset=utf-8"});
saveAs(blob, "save.json");
}
var cheerpjListener = {preloadProgress:showPreloadProgress};
cheerpjInit({listener:cheerpjListener});
//cheerpjInit();
cheerpjCreateDisplay(800,600);
//cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l", "0");
console.log("done");
cheerpjRunJar("/app/Mario-AI-Interface.jar");
var returnVal = cjCall("Play", "otherMain", "0", "f_l", "0");//
returnVal.then(function(e) {
console.log("the return val is ready");
console.log(returnVal);
}).catch(e => console.log("Critical failure: " + e.message));
//console.log(returnVal);
// cheerpjRunJar("/app/Mario-AI-Interface.jar");
// var actionSequenceInBytes = cjCall("MarioProxy", "play", "0", "f_l", "0");
</script>
</html>