Skip to content

tinoism/game-of-life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game of Life (implemented in Rust and FFI to Javascript)

A detailed tutorial for kick starting a Rust and WebAssembly project using wasm-pack.

About

πŸ“š Read this template tutorial! πŸ“š

This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.

Be sure to check out other wasm-pack tutorials online for other templates and usages of wasm-pack.

🚴 Usage

πŸ‘ Use cargo generate to clone the wasm template

Learn more about cargo generate here.

cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
cd my-project

πŸ› οΈ Build with wasm-pack build

After Rust code is ready to go, auto-generate the Javascript FFI from the Rust src folder by running

wasm-pack build

This will then generate the folder ...

To auto-generate the www file

npm init wasm-app www
cd www
npm install (to install webserver)

The www folder will generate a template to connect Javascript/HTML webpage rendering and connect it to the auto-generated Javascript FFI binary.

The index.js file can then be used to display the game. And also, the server will be on localhost:8080.

To run the local host

After you cd into the www folder,

npm run start

πŸ”¬ To connect Javascript to wasm-generated FFI, and create a web interface

wasm-pack test --headless --firefox

🎁 Publish to NPM with wasm-pack publish

wasm-pack publish

πŸ”‹ Batteries Included

About

Rust-Javascript implementation of game of life

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published