Skip to content

Commit

Permalink
feat(helpers): render console.log in game
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed May 27, 2024
1 parent da60357 commit ccb3d27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/helpers/events.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { log } = console

export function addEventListeners(callback: () => void) {
const buttons = document.querySelectorAll(
'.run',
Expand All @@ -14,4 +16,12 @@ export function addEventListeners(callback: () => void) {
debug.log(message)
})
}

// eslint-disable-next-line no-console
console.log = (...args) => {
log(...args)
wait(0, () => {
debug.log(args.join(' '))
})
}
}
3 changes: 3 additions & 0 deletions src/levels/0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const script = `
add([
text('WASD or arrow keys to move')
])
// press "Run" button to see log
console.log('Hello, World!')
`

export function postscript() {}

0 comments on commit ccb3d27

Please sign in to comment.