Re-implementation of Panda Doodle in Rust targetting WASM, a mobile game originally written in C++

Overview

Description

This is the source code of my game Panda Doodle, which can be played at https://pandadoodle.lucamoller.com/ (it's best playable on touch screen devices).

For more information, check out the article I wrote (Rewriting my mobile game in Rust targeting WASM) describing the background, the motivation and my experience while working on this project.

This code was written for fun and originally for my eyes only. I tried to clean/organize things up a bit (believe me it was much messier) in order to share it, but there's so much more that could be done. Also, this code was not intended to be "rusty". On the contrary, I was trying to see how far I could go by writing non-rusty code in Rust (I talk more about this in the article mentioned above). So please forgive me if something hurts your eyes :)

For someone trying to develop games with Rust+WASM, I think the most useful part of this repository is the engine module. It contains the basic functionality for interacting with the browser APIs (like rendering on Canvas2d and input) and also basic frameworks/utilities the game relies on for animations, UI, etc. The code there is fully independent from the game logic and doesn't depend on any game specific logic/types (I guess I could have extracted it in a separate crate). It's not a generic engine with a broad set of features though, it contains exactly the features the required by the game, which were implemented as needed haha.

This repository does not contain all assets to build the functioning Panda Doodle game (static resources such as images, sounds and also puzzle levels descriptions were left out), but it contains all the Rust/JS code used by the game with hopes that someone can learn/reuse something from it. The code should compile, but trying to run the compiled game will fail on the steps that require those assets.

How to install

npm install

How to run in debug mode

# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes.
npm start

How to build in release mode

# Builds the project and places it into the `dist` folder.
npm run build

How to run unit tests

# Runs tests in Firefox
npm test -- --firefox

# Runs tests in Chrome
npm test -- --chrome

# Runs tests in Safari
npm test -- --safari

What does each file do?

  • Cargo.toml contains the standard Rust metadata. You put your Rust dependencies in here. You must change this file with your details (name, description, version, authors, categories)

  • package.json contains the standard npm metadata. You put your JavaScript dependencies in here. You must change this file with your details (author, name, version)

  • webpack.config.js contains the Webpack configuration. You shouldn't need to change this, unless you have very special needs.

  • The html folder contains the index.html file which is the landing page in which the game runs.

  • The js folder contains your JavaScript code (index.js is used to hook everything into Webpack, you don't need to change it).

  • The src folder contains your Rust code.

  • The static folder contains any files that you want copied as-is into the final build.

You might also like...
wasm actor system based on lunatic

Wactor WASM actor system based on lunatic. Actors run on isolated green threads. They cannot share memory, and communicate only through input and outp

swc node binding use wasm

node_swc swc node binding use wasm Build Make sure you have rust wasm-pack installed. $ yarn build # build wasm, node Usage import { parseSync, printS

🦞 wasm-pack based build tool

rsw-rs This project is in early experimental stage. # dev rsw watch # release rsw build # create crate rsw new # rsw.toml name = 'rsw' version = "0.

A shared document application akin to Google Docs. Example usage of wasm-peers library.

Live Document Proof of concept application showcasing the usability of wasm-peers crate for easy and costless peer-2-peer WebRTC communication. It's a

Bindings to the Tauri API for projects using wasm-bindgen

tauri-sys Raw bindings to the Tauri API for projects using wasm-bindgen Installation This crate is not yet published to crates.io, so you need to use

Renders typst code blocks in Obsidian into images using Typst through the power of WASM!
Renders typst code blocks in Obsidian into images using Typst through the power of WASM!

Obsidian Typst Renders typst code blocks into images using Typst through the power of WASM! This is still very much in development, so suggestions/bug

Adapter plugin to use Ruff in dprint's CLI and with JavaScript via Wasm

dprint-plugin-ruff Adapter for Ruff for use as a formatting plugin in dprint. Formats .py and .pyi files. Note: For formatting .ipynb files, use the J

The classic game Pong, written in lambda calculus, and a thin layer of Rust.

What? The good old game Pong, written in lambda calculus, and a thin layer of Rust. Why? I was bored. No, seriously, why? Everyone keeps saying that l

A 3d model, animation and generalized game ripping library written in Rust.

porterlib A 3d model, animation and generalized game ripping library written in Rust. 15k LOC Rust in one weekend and I don't think they can get any b

Comments
  • Static folder is missing

    Static folder is missing

    Although mentioned in the README.md, I couldn't find the static folder in the root directory. As a result, I have a bunch of 404's in Chrome's Dev Console: Screen Shot 2021-09-14 at 01 00 38


    Great work by the way! Love the repo! ❤️ I remember when you first released this game! #nostalgia

    opened by danilo-augusto 0
  • PandaDoodle does not stop running (iOS)

    PandaDoodle does not stop running (iOS)

    Hi!

    first of all, thanks for sharing your game and source code!

    I saw your post about default function arguments on Reddit on Saturday and followed the links towards your wasm game.

    After trying it in my browser (not even installing to Home Screen) iOS reports it running constantly.

    However, it does not show up in the app switcher or in the list of Open Firefox tabs.

    I just noticed through the Screen Time Tracking, which suddenly ramped up, with pandadoodle running constantly since Saturday afternoon:

    A3B61065-8CF6-404C-8289-F5231B20E2D2

    6BFED53D-3356-44F5-916E-345EFC3607D3

    No idea where the bug is - might be in Firefox for iOS or in Safari, which provides the tab and per-website time tracking, but it thought I’ll start here. :)

    cheers! 🐼🖍

    opened by LeoniePhiline 2
Owner
null
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
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
Mobile safari / webview remote debugging and e2e testing libraries

Canter (WIP) (WIP) Mobile safari / webview remote debugging and e2e testing libraries. Developed for safari/webview e2e testing on iPhone. Works only

Han Lee 9 Aug 16, 2022
2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) implementation in Rust with WASM + WebGL

pcisph-wasm 2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) implementation in Rust with WASM + WebGL Reimplementation of my previous Ru

Lucas V. Schuermann 46 Dec 17, 2022
BSV stdlib written in Rust and runs in WASM environments

BSV.WASM A Rust/WASM Library to interact with Bitcoin SV Installation NodeJS: npm i bsv-wasm --save Web: npm i bsv-wasm-web --save Rust: https://crate

null 56 Dec 15, 2022
A wasm interpreter written by rust

A wasm interpreter written by rust

nasa 69 Dec 6, 2022
a wasm interpreter written by rust

wai (WebAssembly interpreter) A simple wasm interpreter This is an ongoing project DEMO 2021-06-27.10.23.18.mov Install Install via Homebrew brew inst

nasa 69 Dec 6, 2022
A reactive DOM library for Rust in WASM

maple A VDOM-less web library with fine-grained reactivity. Getting started The recommended build tool is Trunk. Start by adding maple-core to your Ca

Luke Chu 1.8k Jan 3, 2023
A playground for creating generative art, buit with Rust🦀 and WASM🕸

Genny A playground for creating generative art, buit with Rust ?? and WASM ?? About This is a simple playground that allows me to explore ideas around

João Paiva 3 Mar 12, 2022
A low-ish level tool for easily writing and hosting WASM based plugins.

A low-ish level tool for easily writing and hosting WASM based plugins. The goal of wasm_plugin is to make communicating across the host-plugin bounda

Alec Deason 62 Sep 20, 2022