Breakout - The Classic Arcade Game
Breakout is a retro arcade game where players control a paddle to bounce a ball and break bricks on the screen.
The goal is to clear all the bricks without letting the ball fall off the screen, while aiming to achieve the highest score possible.
The project was built in Rust + Raylib for the front-end, Rust for the back-end, and PostgreSQL for the database. Some of it's core features are:
- User Session: Creating a separate session for each user.
- User Stats: View stats about your most recent as well as your best attempt.
- Leaderboard: View statistics of the top players of the game.
I utilized the following crates to build this project:
- raylib: A C library binding for 2D and 3D game development.
- lazy_static: For safe, one-time, runtime initialization of static variables.
- reqwest: A powerful HTTP client for making network requests, with JSON support.
- rpassword: Allows secure password input without echoing it to the terminal.
- serde: Facilitates serialization and deserialization of data using Rust structs.
- serde_json: Provides JSON parsing and serialization functionality using Serde.
- tokio: Provides a set of utilities for asynchronous programming.
- actix-web: A lightweight web framework for building scalable web applications and APIs in Rust.
- bcrypt: Used for hashing and verifying passwords securely.
- dotenvy: Loads environment variables from a `.env` file for easy configuration management.
- sqlx: An async SQL database client supporting various databases with query validation.
These are a list of supported end-points:
- / - Health Check: A simple endpoint to check if the server is running, returns "OK".
- /user/login - User Login: Allows a user to log in by checking if their gamer_id exists and verifying their password. If not, the user is added to the database.
- /leaderboard - Get Leaderboard: Retrieves the top 5 leaderboard entries, sorted by high score.
- /stats/{gamer_id} - Get User Stats: Retrieves the high score and time for a specific user (gamer_id).
- /update_stats - Update Stats: Allows updating or inserting a user's high score and time. If the user already exists, the highest score is updated and time is adjusted accordingly.
This is how my database tables schema looks like:
- users table:
- Columns:
- gamer_id (type:
varchar(50)
): The unique identifier for each user, serves as the primary key. - password (type:
varchar(255)
): Stores the hashed password for the user.
- gamer_id (type:
- Constraints:
PRIMARY KEY (gamer_id)
: Ensures thatgamer_id
is unique for each user.
- Columns:
- high_score table:
- Columns:
- gamer_id (type:
varchar(50)
): The unique identifier for the user, references thegamer_id
in theusers
table. - high_score (type:
integer
): Stores the highest score achieved by the user. - time (type:
varchar(10)
): Stores the time taken to achieve the high score.
- gamer_id (type:
- Constraints:
PRIMARY KEY (gamer_id)
: Ensures thatgamer_id
is unique for each high score entry.FOREIGN KEY (gamer_id) REFERENCES users(gamer_id) ON DELETE CASCADE
: Ensures that everygamer_id
in thehigh_score
table corresponds to an existing user in theusers
table, and if a user is deleted, their associated high score records are also deleted.
- Columns:
Project information
- Project Demo: View Demo Video
- GitHub Repo: Click Here
- Technologies: Rust, Raylib, PostgreSQL