diff --git a/Makefile b/Makefile index f0d24dd..4d298ab 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ modules = \ modules/dom/window.scm \ modules/math.scm \ modules/math/rect.scm \ - modules/math/vector.scm + modules/math/vector.scm\ + modules/console.scm game.wasm: game.scm $(modules) guild compile-wasm -L modules -o $@ $< diff --git a/game.js b/game.js index 89f0b12..22fefcb 100644 --- a/game.js +++ b/game.js @@ -66,6 +66,9 @@ window.addEventListener("load", async () => { }, math: { random: () => Math.random() + }, + console: { + log: (message) => console.log(message) } }); } catch(e) { diff --git a/game.scm b/game.scm index c77a00a..66544bb 100644 --- a/game.scm +++ b/game.scm @@ -1,13 +1,15 @@ (import (scheme base) (scheme inexact) (hoot ffi) + (hoot debug) (dom canvas) (dom document) (dom element) (dom event) (dom image) (dom media) - (dom window)) + (dom window) + (console)) (define game-width 640.0) @@ -29,3 +31,6 @@ (set-element-height! canvas (exact game-height)) (request-animation-frame draw-callback) + +(dprint "game-height" game-height) +(console-log canvas) diff --git a/modules/console.scm b/modules/console.scm new file mode 100644 index 0000000..3b947f6 --- /dev/null +++ b/modules/console.scm @@ -0,0 +1,10 @@ +(define-module (console) + #:pure + #:use-module (scheme base) + #:use-module (hoot ffi) + #:export (console-log)) + + +(define-foreign console-log + "console" "log" + (ref extern) -> (ref extern))