Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakson-almeida/rasptauri
Guess Game is an educational project designed for beginners in Rust, Sycamore, and Tauri. The game generates a random number between 0 and 100, and the user tries to guess it. The game provides feedback if the guess is too high, too low, or correct.
https://github.com/jakson-almeida/rasptauri
educational game rust sycamore tauri wasm
Last synced: 4 days ago
JSON representation
Guess Game is an educational project designed for beginners in Rust, Sycamore, and Tauri. The game generates a random number between 0 and 100, and the user tries to guess it. The game provides feedback if the guess is too high, too low, or correct.
- Host: GitHub
- URL: https://github.com/jakson-almeida/rasptauri
- Owner: Jakson-Almeida
- Created: 2024-07-10T14:59:13.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-10T16:44:29.000Z (5 months ago)
- Last Synced: 2024-10-31T03:42:18.388Z (about 2 months ago)
- Topics: educational, game, rust, sycamore, tauri, wasm
- Language: Rust
- Homepage:
- Size: 1.73 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Guess Game
## Overview
Guess Game is an educational project designed for beginners in **Rust**, **Sycamore**, and **Tauri**. The game generates a random number between 0 and 100, and the user tries to guess it. The game provides feedback if the guess is too high, too low, or correct.![Guess Game](https://github.com/Jakson-Almeida/RaspTauri/blob/main/public/guess-game.png)
## Technologies
- **Rust**: A system programming language known for performance and safety.
- **Sycamore**: A Rust framework for building reactive web applications.
- **Tauri**: A toolkit for building desktop applications with web technologies and Rust.## What is WebAssembly?
WebAssembly (Wasm) is a binary instruction format for a stack-based virtual machine. It allows code written in multiple languages to run on the web at near-native speed by taking advantage of common hardware capabilities.## Game Logic
The game logic is handled by a Tauri command that checks the user's guess against the randomly generated secret number. The code snippet below shows how Tauri decides if the guess is correct:```rust
#[tauri::command]
fn guess2(name: &str) -> String {
let mut secret_number = SECRET.lock().unwrap();
if *secret_number == 1000 {
*secret_number = get_random();
}let my_int: u32 = match name.trim().parse() {
Ok(num) => num,
Err(_) => return "Invalid input! Please enter a number.".to_string(),
};match my_int.cmp(&*secret_number) {
Ordering::Less => format!("{} is too small!", my_int),
Ordering::Greater => format!("{} is too big!", my_int),
Ordering::Equal => {
*secret_number = 1000;
format!("{} is correct! You win!", my_int)
},
}
}
```Clone the repository:
```bash
git clone https://github.com/Jakson-Almeida/RaspTauri.git
```Navigate to the project directory and install dependencies:
```bash
cd RaspTauri
cd src-tauri
cargo tauri dev
```Enjoy playing the Guess Game and learning about Rust, Sycamore, and Tauri!