-
Notifications
You must be signed in to change notification settings - Fork 2
wasm #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
wasm #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script> | ||
let stats; | ||
|
||
import("../pkg").then(({ Stats, decrease_stats }) => { | ||
stats = Stats.new(); | ||
|
||
let start = null; | ||
|
||
const handleStats = timestamp => { | ||
const elapsedTime = timestamp - start; | ||
start = timestamp; | ||
decrease_stats(stats, elapsedTime / 1000); | ||
stats = stats; // pffffff | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Svelte's neatness? Maybe rewriting as:
would make it less weird There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this won't work because |
||
window.requestAnimationFrame(handleStats); | ||
}; | ||
|
||
window.requestAnimationFrame(handleStats); | ||
}); | ||
</script> | ||
|
||
{#if stats} | ||
<ul> | ||
<li>🍗 {stats.food.value}</li> | ||
<li>💧 {stats.water.value}</li> | ||
<li>⚡️ {stats.energy.value}</li> | ||
<li>❤️ {stats.health.value}</li> | ||
</ul> | ||
{/if} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./App.svelte"; | ||
|
||
const app = new App({ | ||
target: document.body | ||
}); | ||
|
||
window.app = app; | ||
|
||
export default app; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this have
if (start == null) { start = timestamp; return; }
?