Skip to content

Commit

Permalink
fixing basics
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumer committed Sep 3, 2024
1 parent fc09529 commit c88a21b
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 17 deletions.
16 changes: 8 additions & 8 deletions cart/c/sound/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ int main() {

// load a SFX from a file
// currently this is broke
SfxParams* fileloaded = malloc(96);
load_sfx(fileloaded, "assets/sound.rfx");
fileloaded_sfx = new_sfx(fileloaded);
print_sfx(*fileloaded);
// SfxParams* fileloaded = malloc(96);
// load_sfx(fileloaded, "assets/sound.rfx");
// fileloaded_sfx = new_sfx(fileloaded);
// print_sfx(*fileloaded);

return 0;
}
Expand All @@ -98,7 +98,7 @@ void update() {
draw_text(0, "Press X for coin sound.", 65, HEIGHT / 2 - 20, RAYWHITE);
draw_text(0, "Press Y for hurt sound.", 65, HEIGHT / 2, RAYWHITE);
draw_text(0, "Press START for hardcoded sfx struct", 18, HEIGHT / 2 + 20, RAYWHITE);
draw_text(0, "Press SELECT for file sfx", 45, HEIGHT / 2 + 40, RAYWHITE);
// draw_text(0, "Press SELECT for file sfx", 45, HEIGHT / 2 + 40, RAYWHITE);
}

NULL0_EXPORT("buttonDown")
Expand Down Expand Up @@ -133,7 +133,7 @@ void buttonDown(GamepadButton button) {
play_sound(preloaded_sfx, false);
}

if (button == GAMEPAD_BUTTON_SELECT) {
play_sound(fileloaded_sfx, false);
}
// if (button == GAMEPAD_BUTTON_SELECT) {
// play_sound(fileloaded_sfx, false);
// }
}
Binary file modified docs/cart/colorbars.null0
Binary file not shown.
Binary file modified docs/cart/draw.null0
Binary file not shown.
Binary file modified docs/cart/filesystem.null0
Binary file not shown.
Binary file modified docs/cart/flappybird.null0
Binary file not shown.
Binary file modified docs/cart/hello.null0
Binary file not shown.
Binary file modified docs/cart/input.null0
Binary file not shown.
Binary file modified docs/cart/justlog.null0
Binary file not shown.
Binary file modified docs/cart/sound.null0
Binary file not shown.
Binary file modified docs/cart/tracker.null0
Binary file not shown.
Binary file modified docs/cart/typesizes.null0
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<null0-cart src="cart/input.null0" fps></null0-cart>
<null0-cart src="cart/colorbars.null0" fps></null0-cart>
<null0-cart src="cart/draw.null0" fps></null0-cart>
<null0-cart src="cart/hello.null0" fps></null0-cart>
<null0-cart src="cart/flappybird.null0" fps></null0-cart>
<!-- <null0-cart src="cart/hello.null0" fps></null0-cart> -->
<!-- <null0-cart src="cart/flappybird.null0" fps></null0-cart> -->
<null0-cart src="cart/sound.null0" fps></null0-cart>
<null0-cart src="cart/typesizes.null0" fps></null0-cart>
<null0-cart src="cart/filesystem.null0"></null0-cart>
<null0-cart src="cart/justlog.null0"></null0-cart>
<!-- <null0-cart src="cart/typesizes.null0" fps></null0-cart> -->
<!-- <null0-cart src="cart/filesystem.null0"></null0-cart> -->
<!-- <null0-cart src="cart/justlog.null0"></null0-cart> -->
</body>
</html>
9 changes: 6 additions & 3 deletions docs/null0.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export async function setupCart (url, canvas = document.body.appendChild(documen
cart[k] = exports[k]
}

const d = new TextDecoder()
cart.getString = (offset, length) => d.decode(exports.memory.buffer.slice(offset, offset + length))
cart.view = new DataView(exports.memory.buffer)

out.cart = cart

if (cart._start) {
Expand All @@ -124,7 +128,7 @@ export async function setupCart (url, canvas = document.body.appendChild(documen
}

if (cart.buttonDown) {
canvas.addEventListener('keydown', ({key}) => {
canvas.addEventListener('keydown', ({ key }) => {
if (key === 'z') {
cart.buttonDown(Buttons.B)
}
Expand Down Expand Up @@ -165,7 +169,7 @@ export async function setupCart (url, canvas = document.body.appendChild(documen
}

if (cart.buttonUp) {
canvas.addEventListener('keyup', ({key}) => {
canvas.addEventListener('keyup', ({ key }) => {
if (key === 'z') {
cart.buttonUp(Buttons.B)
}
Expand Down Expand Up @@ -205,7 +209,6 @@ export async function setupCart (url, canvas = document.body.appendChild(documen
})
}


const cartUpdate = () => {
if (cart.update) {
cart.update()
Expand Down
2 changes: 1 addition & 1 deletion docs/wasm/null0.mjs

Large diffs are not rendered by default.

Binary file modified docs/wasm/null0.wasm
Binary file not shown.

0 comments on commit c88a21b

Please sign in to comment.