Skip to content

awwsmm/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe

A simple game written in Rust using Bevy.

Try it!

On desktop or mobile, try it out at https://tic-tac-toe.awwsmm.com/

Compiling From Source

Prerequisites

Install rustc, rustup, and cargo by running the following command in a terminal

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Once rustup is properly installed, add the wasm32-unknown-unknown compilation target

rustup target add wasm32-unknown-unknown

Once cargo is properly installed, use it to install the wasm-bindgen-cli

cargo install wasm-bindgen-cli

...and live-server

cargo install live-server

Compiling

Compile the Rust code to WASM with

cargo build --release --target wasm32-unknown-unknown

Generate JavaScript bindings for the WASM output with

wasm-bindgen --out-dir target --target web target/wasm32-unknown-unknown/release/tic-tac-toe.wasm

(Optional) Automatically Recompile

If you want cargo to automatically recompile the Rust code in this repo when it changes, install cargo-watch with

cargo install cargo-watch

...and then set up cargo watch to run the steps in the "Compiling" section, above, automatically

cargo watch -- bash build-and-bind.sh

Note that this will block a terminal, so all other commands will need to be run in a separate terminal window.

Running

Locally

To view the compiled output locally, execute the following command in a terminal

live-server

This should give output like

[2024-02-26T13:38:10Z INFO  live_server::server] Listening on http://192.168.2.24:52746/
[2024-02-26T13:38:10Z INFO  live_server::watcher] Listening on /Users/andrew/Git/tic-tac-toe

You can then view the output by opening the specified address (e.g. http://192.168.2.24:52746/) in a browser.

If you followed the steps in the "Automatically Recompile" section, above, this page will be automatically refreshed as changes are made to the code in this repository.

Press Control-C in the terminal to close the HTTP server.

About

Tic Tac Toe in Bevy / Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages