A redesign of 'WordGrid' in Rust & WebAssembly, featuring both single- & multi- player.
- Rust 57.1%
- TypeScript 37.9%
- Less 2.8%
- HTML 1.4%
- Dockerfile 0.8%
Before, incoming connections for an existing player name were denied. This caused issues if the websocket connection between the client and server was glitched, and the server falsely believed that the client was still connected. When this happened, the player was effectively locked out of reconnecting. I still want to add a better heartbeat system where the client can detect when the connection is glitched and auto-reconnect, but this is a step in that direction. |
||
|---|---|---|
| resources | ||
| server | ||
| ui | ||
| wasm | ||
| wordgrid | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| Dockerfile | ||
| LICENSE | ||
| README.md | ||
README
This repository contains the code for 'WordGrid', a browser game where you use letter tiles to form words.
There is support for both multiplayer and singleplayer, where singleplayer runs entirely in the browser through WebAssembly.
Here's the rough layout of the repository:
- The core game logic resides in the
wordgrid/folder as Rust code and is a library for either thewasm/code (if compiled to WebAssembly for singleplayer), or for theserver/code (if used in multiplayer). - The Rust code in
wasm/is a small compatibility layer between the library and the browser. It gets compiled usingwasm-packto a Node package intowasm/pkg/that gets read byui/ ui/is a Node package that uses React & Typescript. Currently it assumes it's being run in an environment that supports both singleplayer & multiplayer. This can't be built until thewasm/code has been built.server/is a Rust program that runs a small web server for multiplayer purposes.
If you want to try it now, I host a version at https://wordgrid.joeltherrien.ca
Setup
I'd suggest just reading through the Dockerfile to precisely see what to do, but it's basically the following steps:
- Ensure you have Rust, Node, npm, and wasm-pack installed.
- Build wasm by navigating to the
wasm/folder and runningwasm-pack build --target=web - Build the ui by navigating to the
ui/folder and runningnpm run build. You may need to first runnpm install. - Build the server by navigating to the
server/folder and runningcargo build --release.
If you just want singleplayer, you can stop after step 3 and the static files you'll want are in ui/dist/. You can rename singleplayer.html -> index.html if you want to save a click.