A step toward idiomatic Rust, but not the final step.
version: 3.0 date: 2019-05-20 author: bestia.dev repository: GitHub
Hashtags: #rustlang #game #tutorial
My projects on Github are more like a tutorial than a finished product: bestia-dev tutorials.
You can play the game here (hosted on google cloud platform):
git clone firstname.lastname@example.org:bestia-dev/mem3_game.git cd mem3
cargo install --force cargo-make
- build both projects,
- copy pkg folder and index.html into server project,
- run 2 chrome tabs
- run the http+WebSocket server
Please refresh the browser tabs manually after that, so they download the new files.
A little about cargo-make:
Memory game rules
This game is for exactly 2 players.
Both players must have the webpage simultaneously opened in the browser to allow communication.
To start over just refresh the webpage.
The first player clicks on 'Invite for play?' and broadcasts the message over WebSocket.
He can choose different types of play: alphabet, animal,...
Player2 then sees on the screen 'Click here to Accept play!', clicks it and sends the message back to Player1.
The game starts with a grid of 8 randomly shuffled card pairs face down - 16 cards in all.
On the screen under the grid are clear signals which player plays and which waits.
Player1 flips over two cards with two clicks. The cards are accompanied by sounds and text on the screen.
If the cards do not match, the other player clicks on 'Click here to Take your turn' and both cards are flipped back face down. Then it is his turn and he clicks to flip over his two cards.
If the cards match, they are left face up permanently and the player receives a point. He continues to play, he opens the next two cards.
The game is over when all the cards are permanently face up. It means that the sum of points is exactly 8.
Click on "Play again?" to start the game over.
cargo crev reviews and advisory
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
On the web use this url to read crate reviews. Example:
- Only one WorkSpace for the frontend and end backend projects and commons. To see how it works.
- use cargo make (build scripts) to copy needed files to webfolder. This folder can be then copied to some website and works.
- mem3 RenderComponents have an internal cache for values. These are copied/cloned from game_data. ANd invalidated accordingly.
- For the research of different approach to game_data references I opened a new project with minimalistic code.
- player can choose more than one content: "images, sounds and text"
- fetch text.json from Rust asynchronously over WebSocket 2019-05-20 -- re-invite player for different game
- the server broadcasts only the first "Want to play?". All the rest is a private conversation between 2 players.
- use files as separate modules of the same crate
- cached PlayersAndScores
web, http, css
JsValue, future, promises
Images included free cartoon characters: