phoboslab / high_impact

A 2d game engine written in C
MIT License
1.03k stars 73 forks source link

WASM Build Failure: Image Loading Error in high_biolab Post-Commit 31ce1b1 #6

Closed Okabintaro closed 2 weeks ago

Okabintaro commented 2 weeks ago

It seems that the wasm was broken somewhere after commit 31ce1b18b9a52c8727ac5fb63da1bdc2a525faac.

When building for example high_biolab using make wasm, then hosting it with python3 -m http.server it gives me this error in the console:

Abort at "src/../high_impact/src/image.c" line 63: Failed to load image assets/sprites/blob.qoi
game.js:4326 program exited (with status: 1), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)
exitJS @ game.js:4326
game.js:235 Uncaught ExitStatus

I rolled back to 31ce1b18b9a52c8727ac5fb63da1bdc2a525faac and it works fine.

phoboslab commented 2 weeks ago

The WASM build works fine for me with the current master.

Can you try make clean first and then make wasm?

Okabintaro commented 2 weeks ago

I tried it again, doing make clean and still get the error. Also tried with both chromium and firefox. Ever since commit a911337 I get the same error.

Maybe I am building from the wrong folder? Here is what I did:

❯ pwd
/home/oka/dev/repos/high_biolab

❯ ls
assets/  build/  compile_commands.json  high_impact/  Makefile*  README.md  src/

❯ make clean wasm && python3 -m http.server -d build/wasm/
...

I can gonna investigate further later, but I am currently working on a game jam game with the engine. It's really fun to work with and the code is nice and readable. Thanks for putting it out here.

phoboslab commented 2 weeks ago

My apologies, I tested with the wrong version. The problem should be fixed with https://github.com/phoboslab/high_impact/commit/8d5e4e0008b5c23eef0cc9f9806f9f8db4996257

Glad to hear you enjoy working with the engine! Can you post your game here, once it's done?

Okabintaro commented 2 weeks ago

Hey, thanks for the quick fix. It works great. I submitted my game for the jam, you can see the source here or play it on itch.io

I love how small a build can get. If I would use a mod instead of qoa for the music, the whole game would probably below 300kb.

Weltmeister is a nice editor too and it being just js it seems easy to extend and adapt too. There are a bunch of features I wish it had like copying and pasting from multiple layers, multi select and move entities, lock(make unclickable or hide) entities. Think I might give it a try extending it myself a bit. The guys from CrossCode seemed to be happy with it too and how they were able to extended it.

phoboslab commented 2 weeks ago

Neat! I tweeted about it here.

For sound/music I was thinking about porting Sonant-X (from https://github.com/phoboslab/q1k3/blob/master/source/audio.js) to C. This thing worked so nicely for the music in Q1K3 and also lets you create a lot of sound effects easily – somewhat similar to SFXR.

Weltmeister definitely needs some upgrades. I actually have a complete rewrite on my drive already, but it was tightly integrated into what would have become Impact2. Untangling this will be a bit of work...

I also noticed that your game flips gravity, which will trip up the on_ground flag for physics. That's something I should probably fix...

Anyway, congrats for finishing this game! It plays very well and looks quite cute :)

Okabintaro commented 2 weeks ago

Neat! I tweeted about it here. Anyway, congrats for finishing this game! It plays very well and looks quite cute :)

Thanks! It was very fun to make, the engine provided a nice framework.

For sound/music I was thinking about porting Sonant-X (from https://github.com/phoboslab/q1k3/blob/master/source/audio.js) to C. This thing worked so nicely for the music in Q1K3 and also lets you create a lot of sound effects easily – somewhat similar to SFXR.

Oh, that looks cool. I found stb_hexwave that does something similar but didn't have the chance to try it out yet. For music I thought about just using jar_xm or libxm in the future. There are some nice public domain modules on modarchive and milkytracker is a nice opensource tracker I used some time ago.

Weltmeister definitely needs some upgrades. I actually have a complete rewrite on my drive already, but it was tightly integrated into what would have become Impact2. Untangling this will be a bit of work...

Nice! I am looking forward to it when you get the chance to clean it up. I wanted to try out LDtk as an editor too, and might try writing a loader or converter for it sometime in the future.

I also noticed that your game flips gravity, which will trip up the on_ground flag for physics. That's something I should probably fix...

Ah I played around with that idea but didn't use it in the end. Maybe for a future game :) Got it to work with a simple patch doing this in entity.c:

@@ -436,8 +432,18 @@ static void entity_handle_trace_result(entity_t *self, trace_t *t) {
                if (t->normal.y < -self->min_slide_normal) {
                        self->vel.y = self->vel.x * t->normal.x;
                }
+       } else if (engine.gravity < 0 && t->normal.y > -self->max_ground_normal) {
+               // upside down gravity
+               self->on_ground = true;
+
+               // If we don't want to slide on slopes, we cheat a bit by
+               // fudging the y velocity.
+               if (t->normal.y > -self->min_slide_normal) {
+                       self->vel.y = self->vel.x * t->normal.x;
+               }
        }
-       
+
+