Giter Site home page Giter Site logo

lukewilliamboswell / roc-wasm4 Goto Github PK

View Code? Open in Web Editor NEW
45.0 5.0 3.0 908 KB

Build wasm4 games using Roc

Home Page: https://lukewilliamboswell.github.io/roc-wasm4/

License: Universal Permissive License v1.0

Zig 87.25% Shell 0.42% Roc 12.32%
roc-lang wasm4

roc-wasm4's Issues

Unable to `zig build run` on Mac M2 Max Sonoma 14.4.1 and zig 0.13.0-dev.267+793f820b3

I cloned the repo and typed: zig build run but get this:

glenn@glenn-MacM2Pro ~/src/github.com/lukewilliamboswell/roc-wasm4 (main) $ zig build run
/Users/glenn/src/github.com/lukewilliamboswell/roc-wasm4/build.zig:19:33: error: no field named 'path' in union 'Build.LazyPath'
        .root_source_file = .{ .path = "build_roc.zig" },
                                ^~~~
/usr/local/zig-macos-aarch64-0.13.0-dev.267+793f820b3/lib/std/Build.zig:2133:22: note: union declared here
pub const LazyPath = union(enum) {
                     ^~~~~
referenced by:
    runBuild__anon_8350: /usr/local/zig-macos-aarch64-0.13.0-dev.267+793f820b3/lib/std/Build.zig:2079:37
    main: /usr/local/zig-macos-aarch64-0.13.0-dev.267+793f820b3/lib/compiler/build_runner.zig:300:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
glenn@glenn-MacM2Pro ~/src/github.com/lukewilliamboswell/roc-wasm4 (main) $ zig version
0.13.0-dev.267+793f820b3

A Google search was not terribly helpful for a zig newbie, unfortunately.

Any ideas how to fix this?

Screen glitching and long `roc_alloc` call times

Hello -
Having a great time writing my Real-Time-Strategy game in roc-wasm4! However, when my update function makes multiple roc_alloc calls, the ensuing frame "glitches", showing garbage on parts of the screen.

Below is a profile showing the issue. Most frames generated are "clean" like the two on the left. You can see the "glitch" in the right-most frame -- there's noise over the game's text at the bottom of the screen.
Annotated Profile With Glitch

This always happens after update runs this A* search function (which, in turn, triggers a number of roc_alloc calls). Here is a zoomed-in version of the update call from the previous screenshot. As you can see, the recursion is fairly deep but not at all wide -- the vast majority of time is spent in the bit_set_ArrayBitSet.isSet call.
Zoomed In update

I've also found the glitching:

  • Happens both natively and in the browser.
  • Gets worse (covers more of the screen, shows more noise) the more roc_alloc calls update makes.
  • Reflects what's actually in the frame buffer memory (calling getPixel() on a noisy pixels returns the noise color).

Should I simply get better at managing allocations? Or is this potentially a bug in roc-wasm4, roc, wasm4, zig or wasm?

Unused defs cause build to fail

This program runs successfully, but if I comment out either the unused import or the unused def, the build fails.

app "drum"
    packages {
        w4: "platform/main.roc",
    }
    imports [
        w4.Task.{ Task },
        # w4.W4,
    ]
    provides [main, Model] to w4

Program : {
    init : Task Model [],
    update : Model -> Task Model [],
}

Model : {}

main : Program
main = { init, update }

init : Task Model []
init =
    Task.ok {}

update : Model -> Task Model []
update = \model ->
    Task.ok model

# unused = "foo"
$ zig build -Dapp=foo.roc run

── UNUSED DEFINITION ───────────────────────────────────────────────── foo.roc ─

unused is not used anywhere in your code.

29│  unused = "foo"
     ^^^^^^

If you didn't intend on using unused then remove it so future readers
of your code don't wonder why it is there.

────────────────────────────────────────────────────────────────────────────────

0 errors and 1 warning found in 13 ms.
run roc: error: the following command exited with error code 1:
roc check /Users/isaacvando/Desktop/projects/roc-drum-machine/foo.roc 
Build Summary: 0/5 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run w4 transitive failure
   └─ zig build-lib cart Debug wasm32-freestanding transitive failure
      └─ run roc transitive failure
         └─ run roc failure
error: the following build command failed with exit code 1:
/Users/isaacvando/Desktop/projects/roc-drum-machine/zig-cache/o/c173747dba52ae0f3be002aa3cb112b9/build /Users/isaacvando/Desktop/projects/zig/build/zig /Users/isaacvando/Desktop/projects/roc-drum-machine /Users/isaacvando/Desktop/projects/roc-drum-machine/zig-cache /Users/isaacvando/.cache/zig -Dapp=foo.roc run

I am using the most recent version of the platform, roc from Jan 12, and apple silicon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.