A collection of small games for the Fantasy Console WASM-4

Overview

WASM-4 Tutorial Games

This repo contains the source code for different tutorial games for the Fantasy Console WASM-4.

The goal is to provide a one-stop-repo for all tutorials hosted on the WASM-4 website.

Snake

Snake

A famous game that can be implemented in pretty much any language, engine of framework.

It's currently implemented in: AssenblyScript, C, Go, Odin and Rust.

Comments
  • Smol rust

    Smol rust

    Not intended to merge in its current state. Just creating this PR for discussion purposes.

    Used https://rustwasm.github.io/book/reference/code-size.html for some guidance. In particular this poitned me toward wasm-snip. I used it here to snip out panic code, which is probably what we'd want in most cases, and also to strip out formatting code. The latter is a bit more aggressive and could break things if the game is using Rust's string formatting other than in panics.

    Un-post-processed release build on main: ~140 KB

    $ cargo build --release
    $ ls -go target/wasm32-unknown-unknown/release/*.wasm
    -rwxrwxr-x 2 140570 Jan  2 09:26 target/wasm32-unknown-unknown/release/snake_w4_rs.wasm
    

    wasm-opt only on main: ~99 KB

    $ cargo build --release
    $ wasm-opt -Oz --strip-producers --dce --zero-filled-memory target/wasm32-unknown-unknown/release/*.wasm -o optimized.wasm
    $ ls -go optimized.wasm 
    -rwxrwxr-x 1 99304 Jan  2 09:30 optimized.wasm
    

    wasm-opt + wasm-strip (strips out debug info) on main (EDIT: you can also just add the --strip-debug flag when calling wasm-opt): ~22 KB

    $ cargo build --release
    $ wasm-opt -Oz --strip-producers --dce --zero-filled-memory target/wasm32-unknown-unknown/release/*.wasm -o optimized.wasm
    $ wasm-strip optimized.wasm
    $ ls -go optimized.wasm 
    -rwxrwxr-x 1 22562 Jan  2 09:31 optimized.wasm
    

    wasm-opt + wasm-strip + wasm-snip on main: ~13 KB

    $ cargo build --release
    $ cp target/wasm32-unknown-unknown/release/*.wasm optimized.wasm
    $ wasm-snip --snip-rust-fmt-code --snip-rust-panicking-code -o optimized.wasm optimized.wasm
    $ wasm-strip optimized.wasm
    $ wasm-opt -Oz --strip-producers --dce --zero-filled-memory optimized.wasm -o optimized.wasm
    $ ls -go optimized.wasm 
    -rwxrwxr-x 1 12887 Jan  2 09:35 optimized.wasm
    

    wasm-opt + wasm-strip + wasm-snip + remove usage of Mutex and lazy_static: ~7 KB

    $ ./build.sh
    $ ls -go optimized.wasm 
    -rwxrwxr-x 1 6876 Jan  2 09:36 optimized.wasm
    
    opened by sporksmith 2
  • Add Platformer (AssemblyScript) example to tutorials

    Add Platformer (AssemblyScript) example to tutorials

    Added an example of how to make a simple 2D platformer game for WASM-4.

    There are many ways of doing a platformer. This one evolved from the Maze example and uses bounding boxes to check all the collisions.

    Platformers are one of the very first things people want to make once they get introduced to a new engine or platform. That said, an example like this can be extremely valuable to introduce people to WASM-4 and serve as a base for people to use and evolve from it.

    opened by MrRafael-dev 1
  • refactor(rust): apply linter (clippy) suggestions

    refactor(rust): apply linter (clippy) suggestions

    $ cargo clippy
    warning: called `is_some()` after searching an `Iterator` with `find`
      --> src/snake.rs:98:18
       |
    98 |                   .find(|&body_section| body_section == first)
       |  __________________^
    99 | |                 .is_some(),
       | |__________________________^ help: use `any()` instead: `any(|body_section| body_section == first)`
       |
       = note: `#[warn(clippy::search_is_some)]` on by default
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
    
    • https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
    opened by FaberVitale 1
  • Added C Version

    Added C Version

    Tried to keep it as direct a port as possible but it necessitated a few support functions, snake_create and snake_push. The rest is almost a literal port.

    opened by thedavesims 1
  • Simplified code for tutorial

    Simplified code for tutorial

    Replaced include guard with #pragma once for brevity.

    Removed malloc to simplify snake_create and remove non-portable code.

    Replaced struct assignment with field assignment for clarity.

    opened by thedavesims 0
  • Rust Snake example rewritten

    Rust Snake example rewritten

    There were a few complaints about the file size of the Rust Snake example (~141KB; ~100KB with wasm-opt).

    Some possible issues for this are:

    • Use of external crates (lazy-static and fastrand) may contribute to the overall size.
    • Idiomatic Rust could be adding too much bloat into the code and may not be the best choice for keeping a balance between size optimization and easy-to-understand code.

    I decided to rewrite everything and see if I could provide an example which would output a smaller file size while still being easy to explain to a beginner. The following changes were made:

    • lazy-static was removed in favour of using static mut.
    • fastrand was removed in favor of a simple rand() function using Xorshift algorithm.
    • Everything is now part of one single lib.rs file.
    • Code is almost fully documented.

    There are still a few things to fix:

    • Improve source code formatting.
    • Re-split each section into separate files if needed.
    • Comment the remaining parts of code.
    • Resolve some TODOs left in the code.

    With all these changes, Rust Snake now only has ~72KB of file size (~10KB with wasm-opt).

    opened by MrRafael-dev 0
Owner
Chris
Chris
2D real-time mutliplayer game in a browser. Showcase of the usability of wasm-peer crate.

Footballers Description 2D real-time multiplayer game in a browser. Players divided in two teams play a football match on field with two goal posts. G

null 10 Dec 22, 2022
Just a little game I made in a day to try out the WASM-4 fantasy console.

Dodgeball This is just a little game I made in a day to try out the WASM-4 fantasy console. Play it here. The palette is SODA-CAP by Cappuchi. License

Sander in 't Veld 1 Jan 15, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
👾 Run WebAssembly (WASM-4) games on small devices (like PyBadge)

?? gamgee Run WebAssembly (WASM-4) games on small devices. Gamgee is a WASM-4 games emulator written in Rust and designed to be executed on devices wi

Orsinium Labs 5 Feb 27, 2024
Grebuloff is an experimental addon framework for Final Fantasy XIV.

Grebuloff Grebuloff is an experimental addon framework for Final Fantasy XIV. It introduces a new concept of what plugins can be, focusing on enabling

Ava Chaney 5 Jun 11, 2023
Overlay DPS Meter for Granblue Fantasy: Relink

gbfr-logs Experimental overlay DPS meter for Granblue Fantasy: Relink, based on the reverse engineering work from naoouo/GBFR-ACT. Screenshots DPS Ove

null 44 Mar 12, 2024
A single-threaded polling-based Rust async executor suitable for use in games, embedded systems or WASM.

simple async local executor An Enlightware® software. Overview A single-threaded polling-based executor suitable for use in games, embedded systems or

Enlightware GmbH 16 Nov 15, 2022
Cross-platform (including wasm) persistent key value store plugin for rust games/apps

bevy_pkv bevy_pkv is a cross-platform persistent key value store for rust apps. Use it for storing things like settings, save games etc. Currently, it

Johan Klokkhammer Helsing 25 Jan 9, 2023
A small program which makes a rofi game launcher menu possible by creating .desktop entries for games

rofi-games A small program which makes a `rofi` game launcher menu possible by creating `.desktop` entries for games Installation Manual Clone repo: g

Rolv Apneseth 20 May 4, 2023
The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

null 2 Jan 17, 2022
WASM runtime for Deku and Michelson-to-WASM compiler

Tuna This repository has two different projects, a plugable VM for running WASM contracts on Deku and a Michelson to WASM compiler which also has some

Marigold 6 Nov 17, 2022
Distribute a wasm SPA as HTML by wrapping it as a polyglot "html+wasm+zip"

A packer that adds a webpage to WASM module, making it self-hosted! Motivation At the moment, Browsers can not execute WebAssembly as a native single

Andreas Molzer 3 Jan 2, 2023
A Wasm component optimizer (mostly a wrapper around wasm-opt)

component-opt An optimizer for Wasm Components Current Status This project currently only offers one optimization and does not allow it to be configur

Robin Brown 6 Mar 4, 2024
A collection of small Rust programs for doing weird things

This is a repo of small programs, proof of concepts, or templates written in Rust that relate in some way to hacking and/or CTF. I think Rust is real

d3npa 22 Nov 9, 2022
A Rust library containing a collection of small well-tested primitives.

Gazebo - a library of Rust utilities This library contains a collection of well-tested utilities. Most modules stand alone, but taking a few represent

Meta Incubator 168 Dec 29, 2022
A small collection of procedural dungeon generation algorithms.

mapgen A small collection of procedural dungeon generation algorithms. Built with Rust & macroquad. WebAssembly build deployed here. Animated version

null 16 Aug 17, 2022
A small cli demo of rust&wasm hostcall framework.

A Cli Example for Rust and WebAssembly Hostcall Usage # build wasms for ervery module in the `wasm` directory and move them to the root directory # ex

BC2022 3 Aug 29, 2022
Small game where you play a big spider chasing small spiders, written in Rust and Macroquad.

Ludum Dare #49 Compo entry - Procedural Spider Small game where you play a big spider chasing small spiders. Each spider you catch makes you bigger! C

Jakub Arnold 16 Sep 5, 2022
Console progress bar for Rust

Terminal progress bar for Rust Console progress bar for Rust Inspired from pb, support and tested on MacOS, Linux and Windows Documentation Examples s

Ariel Mashraki 507 Dec 22, 2022
tokio-console prototypes

tokio-console prototypes ⚠️ extremely serious warning: this is pre-alpha, proof-of-concept software! currently, the wire format has no stability guara

Tokio 2.3k Jan 3, 2023