[feat] add console log module
This commit is contained in:
parent
e970ed8706
commit
9c2f4c1c5f
4 changed files with 21 additions and 2 deletions
3
Makefile
3
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 $@ $<
|
||||
|
|
3
game.js
3
game.js
|
@ -66,6 +66,9 @@ window.addEventListener("load", async () => {
|
|||
},
|
||||
math: {
|
||||
random: () => Math.random()
|
||||
},
|
||||
console: {
|
||||
log: (message) => console.log(message)
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
|
|
7
game.scm
7
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)
|
||||
|
|
10
modules/console.scm
Normal file
10
modules/console.scm
Normal file
|
@ -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))
|
Loading…
Reference in a new issue