gamercade-io / gamercade_console

A Neo-Retro Fantasy Console. Make WASM-powered, networked multiplayer games.
https://gamercade.io
Apache License 2.0
169 stars 10 forks source link

Feature: Create a bundler for the gamercade ecosystem #68

Closed Cardosaum closed 2 years ago

Cardosaum commented 2 years ago

Currently, the developer experience when creating games or contributing to the source code of the project is quite laborious.

For example, to generate a working version of a custom game first one need to open the editor, select the generated wasm for its game, then export it as gcrom.

We could automate this exporting process by creating a bundler that takes the wasm and any relevant assets file and automatically produces a gcrom as output.

An idea of such working bundler could be:

cargo run --bin editor my_game.wasm my_game.gce my_game

Where my_game.wasm is the game code itself, my_game.gce is the assets file and my_game is the gcrom output file.


Disclaimer: The original idea was from @RobDavenport, I'm just creating the tracking issue for the feature.

RobDavenport commented 2 years ago

This could be related to #30 and #12 but I'm open to any kind of suggestions here.

I think this could either be added to the editor as optional command line arguments, or possibly as a combination new binary & related crate... like gamercade_bundler tool and gamercade_fs crate or something.

New Crate & Additional CLI Tool

Pros

Cons

Overall, I think this is a better approach - what do you think @Cardosaum ?

RobDavenport commented 2 years ago

After our short discussion on Discord, I think the correct steps to do this will be something like follows...

  1. Create a new crate, lets say gamercade_fs which is to handle saving/loading from disk. This would need to include both the .gce, and .gcrom files. The code to do this already exists in parts of the editor and console.
  2. Modify the console and editor to now use this crate for saving and loading.
  3. Create another new crate, lets say gamercade_bunder (or whatever name makes sense), and then just hook it up to use gamercade_fs.

I'm not too picky on the names, and it might be worth it to split this up into two separate PRs, one for steps 1 & 2, and a second one for step 3.

I can definitely help with this issue since there's actually some big changes needed, but not necessarily compelx ones.

RobDavenport commented 2 years ago

Comment from Andre_LA on Discord:

Just read now, I think using CLI args on the editor executable is better (like gamercade_editor bundle -i build/game.wasm -o build/game.gcrom) than making a new application just for that, and maybe this combined with a gamercade_console build/game.wasm --watch command would make it better, however, I generally use the terminal a lot.

For instance, on wasm-4, there is the w4 watch command, with it just saving the code will recompile and re-run the game automatically, which makes the development much more practical.

Finally, I think it's pretty important to not depend on cargo or rust, I actually don't have Rust or Cargo installed (nothing against rust btw :v), and this non-requirement it's a good thing.

RobDavenport commented 2 years ago

These are definitely fair points! I think the end goal here is to not make the bundler application a requirement, but only an alternative. And the first step for that would be to add the saving/loading/exporting logic into it's own library. Then, we can add the saving/loading/exporting logic to whatever other applications we need in the future. The bundler would just be a streamlined one, which could be invoked either by users or by CI/CD instances to keep things up to date.

If we can get the bundler to work using arguments, then it should be easy to add that additional logic to the console later.

I really like the idea of the gamercade_console build/game.wasm --watch. It might need to be adjusted to also include the path to the .gce file so it knows which assets to pull in each time, but alternatively it could actually just load up an already-exported .gcrom for assets, and then just pull in the new .wasm code whenever its ready.

Perhaps the command should look something like this? With an -assets flag and -code flag? We can then read the file extension. Or should another flag exist? like -ae and -ar for editor and rom?