first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import game "../src"
|
||||
import "base:runtime"
|
||||
|
||||
// ignored
|
||||
main :: proc() {}
|
||||
|
||||
is_init: bool
|
||||
|
||||
init_hook :: proc() {
|
||||
global_ctx := runtime.default_context_ptr()
|
||||
game.init(global_ctx)
|
||||
}
|
||||
|
||||
exit_hook :: proc() {
|
||||
game.exit()
|
||||
}
|
||||
|
||||
update_hook :: proc() -> bool {
|
||||
return game.update()
|
||||
}
|
||||
|
||||
@(export)
|
||||
step :: proc(delta_time: f64) -> bool {
|
||||
if !is_init {
|
||||
init_hook()
|
||||
is_init = true
|
||||
}
|
||||
|
||||
if !update_hook() {
|
||||
exit_hook()
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Example 1</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="text/javascript" src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
(async () => {
|
||||
await import("./odin.js"); // from the 'sys/wasm/js'
|
||||
|
||||
let mem = new odin.WasmMemoryInterface()
|
||||
|
||||
let js_log = {
|
||||
trace: (str_ptr, str_len) => console.trace(mem.loadString(str_ptr, str_len)),
|
||||
debug: (str_ptr, str_len) => console.debug(mem.loadString(str_ptr, str_len)),
|
||||
info : (str_ptr, str_len) => console.info(mem.loadString(str_ptr, str_len)),
|
||||
warn : (str_ptr, str_len) => console.warn(mem.loadString(str_ptr, str_len)),
|
||||
error: (str_ptr, str_len) => console.error(mem.loadString(str_ptr, str_len)),
|
||||
};
|
||||
|
||||
let extra = {
|
||||
'js_log' : js_log
|
||||
};
|
||||
await odin.runWasm("./game.wasm", null, extra, mem);
|
||||
})();
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user