Added full-screen toggle option in start menu.
- Added 'toggle_full_screen' key binding to json file. - Implemented full-screen functionality in rats.py.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"start_game": ["Return", 13],
|
"start_game": ["Return", 13],
|
||||||
|
"toggle_full_screen": ["F"],
|
||||||
"quit": ["Q", 12]
|
"quit": ["Q", 12]
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,7 @@ class MiceMaze(controls.KeyBindings):
|
|||||||
self.background_texture = self.engine.create_texture(texture_tiles)
|
self.background_texture = self.engine.create_texture(texture_tiles)
|
||||||
self.engine.draw_background(self.background_texture)
|
self.engine.draw_background(self.background_texture)
|
||||||
|
|
||||||
|
|
||||||
def game_over(self):
|
def game_over(self):
|
||||||
if self.game_end[0]:
|
if self.game_end[0]:
|
||||||
if not self.game_end[1]:
|
if not self.game_end[1]:
|
||||||
@@ -121,7 +122,7 @@ class MiceMaze(controls.KeyBindings):
|
|||||||
rows = f.read().splitlines()
|
rows = f.read().splitlines()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
table.append(row.split(" - "))
|
table.append(row.split(" - "))
|
||||||
table.sort(key=lambda x: int(x[1]), reverse=True)
|
table.sort(key=lambda x: int(x[1]), reverse=True)
|
||||||
return table
|
return table
|
||||||
|
|
||||||
def update_maze(self):
|
def update_maze(self):
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<!doctype html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>WASM test with XHR</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
const importObject = {
|
||||||
|
my_namespace: {
|
||||||
|
imported_func: arg => {
|
||||||
|
console.log(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const request = new XMLHttpRequest();
|
||||||
|
request.open("GET", "rats.wasm");
|
||||||
|
request.responseType = "arraybuffer";
|
||||||
|
request.send();
|
||||||
|
|
||||||
|
request.onload = () => {
|
||||||
|
const bytes = request.response;
|
||||||
|
WebAssembly.instantiate(bytes, importObject)
|
||||||
|
.then(obj => {
|
||||||
|
obj.instance.exports.exported_func();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { promisify } = require('util');
|
||||||
|
|
||||||
|
const fileRead = promisify(fs.readFile);
|
||||||
|
|
||||||
|
(async function() {
|
||||||
|
const wasmBuffer = await fileRead('./rats.wasm');
|
||||||
|
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
||||||
|
const wasmInstance = await WebAssembly.instantiate(wasmModule);
|
||||||
|
|
||||||
|
// Assuming the WASM module exports a function named 'myFunction'
|
||||||
|
console.log('Result from myFunction:', wasmInstance.instance.exports.myFunction());
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user