Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.

Commit f1ca1c8

Browse files
VianpyroVianpyro
andauthored
Modularize code (#17)
* Add game mechanics and UI components for Rust-Pong - Implement ball physics and behavior in `ball.rs` - Create racket mechanics and controls in `racket.rs` - Add score tracking functionality in `score.rs` - Introduce AI controller logic in `controller.rs` - Develop HUD and pause screen stubs in `hud.rs` and `pause_screen.rs` - Update module structure in `mod.rs` files for better organization * Remove unused modules and refactor imports for cleaner code structure * Remove re-exports from game and player modules for cleaner structure * bump version to 1.0.1 in Cargo.toml * Refactor UI components: implement game over and pause screen rendering, update HUD drawing * Fix formatting of continue text in game over screen * Refactor UI: centralize title drawing logic into common module * Update README.md with project details and add LICENSE file * Super-Linter: Fix linting issues * Update README.md: clarify notes on sound effect files and distribution * Fix formatting issues in README.md * Super-Linter: Fix linting issues * Update super-linter workflow: upgrade actions and dependencies * Update super-linter workflow: adjust credential persistence and filter regex * Update super-linter workflow: refine filter regex and add Rust Clippy options * Update super-linter workflow: add validation for GitHub Actions Zizmor * Update super-linter workflow: add fetch for PR base branch to improve changed-files detection * Update super-linter workflow: add debug step for workspace and event details; enable validation for all codebase * Update super-linter workflow: enable Rust Clippy fixer for all events --------- Co-authored-by: Vianpyro <vianney@veremme.org>
1 parent 72c060d commit f1ca1c8

File tree

22 files changed

+218
-93
lines changed

22 files changed

+218
-93
lines changed

.github/workflows/super-linter.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: Checkout code
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2424
with:
2525
fetch-depth: 0
2626

@@ -33,24 +33,29 @@ jobs:
3333
prettier --write .
3434
3535
- name: Super-linter
36-
uses: super-linter/super-linter/slim@v7
36+
uses: super-linter/super-linter/slim@v8
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
VALIDATE_ALL_CODEBASE: false
40-
FILTER_REGEX_EXCLUDE: "(.devcontainer/Dockerfile|.github/pull_request_template.md|.github/ISSUE_TEMPLATE/*.md)"
39+
VALIDATE_ALL_CODEBASE: true
40+
FILTER_REGEX_EXCLUDE: "(.devcontainer/Dockerfile|.github/pull_request_template.md|.github/ISSUE_TEMPLATE/*.md|.github/workflows/*.(yml|yaml))"
4141
# Disable problematic validators
42+
VALIDATE_BIOME_FORMAT: false
4243
VALIDATE_DOCKERFILE_HADOLINT: false
4344
VALIDATE_GIT_COMMITLINT: false
45+
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
4446
# Enable fixers for PR events
4547
FIX_JSON: true
4648
FIX_JSON_PRETTIER: true
4749
FIX_MARKDOWN: true
4850
FIX_MARKDOWN_PRETTIER: true
4951
FIX_NATURAL_LANGUAGE: ${{ github.event_name == 'pull_request' }}
52+
FIX_RUST_CLIPPY: true
53+
# Custom options for linters
54+
RUST_CLIPPY_COMMAND_OPTIONS: "--config max_width=160"
5055

5156
- name: Commit and push fixes
5257
if: github.event_name == 'pull_request' && github.event.pull_request.head.ref != github.event.repository.default_branch
53-
uses: stefanzweifel/git-auto-commit-action@v5
58+
uses: stefanzweifel/git-auto-commit-action@v7
5459
with:
5560
branch: ${{ github.event.pull_request.head.ref }}
5661
commit_message: "Super-Linter: Fix linting issues"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "Rust-Pong"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
authors = ["Vianpyro"]
55
edition = "2024"
66

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Vianney Veremme
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1-
# Template
1+
# Rust-Pong
22

3-
Solid GitHub template repository
3+
Welcome to the **Rust-Pong** repository! This repository contains a small Pong clone implemented in Rust to demonstrate modular game structure, audio, and simple UI.
4+
5+
## 🚀 Getting Started
6+
7+
To get started with this project:
8+
9+
1. Clone the repository:
10+
```bash
11+
git clone https://github.com/Vianpyro/Rust-Pong.git
12+
cd Rust-Pong
13+
```
14+
2. Install the Rust toolchain if you don't already have it: <https://rustup.rs/>
15+
3. Build the project:
16+
```bash
17+
cargo build
18+
```
19+
4. Run the game:
20+
```bash
21+
cargo run --release
22+
```
23+
24+
> [!NOTE]
25+
>
26+
> - Sound effect files (sfx) are embedded in the binary, so you don't need to include them when distributing the executable.
27+
> - If you encounter platform-specific audio or windowing issues, ensure the required system libraries (for audio/display) are available for your OS.
28+
29+
## 📁 Project Structure
30+
31+
The repository contains the following directories and files (high level):
32+
33+
- `assets/` - Game assets (sounds, images, etc.)
34+
- `src/` - Application source code
35+
- `audio/` - Audio handling
36+
- `game/` - Game objects and physics (ball, racket, score)
37+
- `player/` - Player and controller code
38+
- `ui/` - Menus, HUD, and screens
39+
- `main.rs` - Application entry point
40+
- `main_state.rs`, `debug.rs` - Game state and debugging helpers
41+
- `Cargo.toml` - Rust package manifest
42+
- `LICENSE` - Project license (see file for terms)
43+
44+
## 🛠 Features
45+
46+
- Rust-based Pong clone demonstrating basic game loop, physics, and UI.
47+
- Modular code organization (audio, game logic, players, UI).
48+
- Lightweight and easy to extend for experimentation or learning.
49+
50+
## 📖 Documentation
51+
52+
The code is organized into clear modules under `src/`. For details, explore the following files and folders:
53+
54+
- `src/game/` — core game logic and physics
55+
- `src/audio/` — audio playback and resource handling
56+
- `src/ui/` — UI screens (menu, HUD, pause, game over)
57+
58+
Expand this readme as the project grows to include contribution guidelines, a development roadmap, and detailed architecture notes.
59+
60+
## 🤝 Contributing
61+
62+
Contributions are welcome. Suggested workflow:
63+
64+
1. Fork the repository.
65+
2. Create a feature branch: `git checkout -b feature/your-feature`
66+
3. Make your changes and add tests where applicable.
67+
4. Open a pull request to the main repository.
68+
69+
When opening issues or PRs, provide reproduction steps and any relevant logs or OS details.
70+
71+
## 📝 License
72+
73+
See the [`LICENSE`](/LICENSE) file in this repository for license terms.
74+
75+
Happy coding! 🎉
File renamed without changes.

src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use ggez::graphics::{Canvas, Color, DrawMode, DrawParam, Mesh, PxScale, Text};
21
use ggez::{Context, GameResult, glam::Vec2};
2+
use ggez::graphics::{Canvas, Color, DrawMode, DrawParam, Mesh, PxScale, Text};
33

44
pub struct DebugInfo {
55
enabled: bool,
File renamed without changes.

src/game/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub mod ball;
2+
pub mod physics;
3+
pub mod racket;
4+
pub mod score;

src/physics.rs renamed to src/game/physics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::ball::{BALL_SIZE, BALL_SPEED_INCREMENT, BALL_SPEED_MAX, Ball};
2-
use crate::racket::{RACKET_HEIGHT_HALF, RACKET_WIDTH_HALF, Racket};
1+
use crate::game::ball::{BALL_SIZE, BALL_SPEED_INCREMENT, BALL_SPEED_MAX, Ball};
2+
use crate::game::racket::{RACKET_HEIGHT_HALF, RACKET_WIDTH_HALF, Racket};
33

44
#[derive(Debug, Clone, Copy, PartialEq)]
55
pub enum Player {

src/racket.rs renamed to src/game/racket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::controller::{Controller, RacketAction::*};
1+
use crate::player::controller::{Controller, RacketAction::*};
22
use ggez::graphics::{Canvas, Color, DrawParam, Mesh, Rect};
33
use ggez::{Context, GameResult};
44

@@ -33,7 +33,7 @@ impl Racket {
3333
canvas.draw(&self.racket_mesh, DrawParam::default().dest([self.position_x, self.position_y]));
3434
}
3535

36-
pub fn update(&mut self, input: &crate::controller::ControllerInput, delta_time: f32) {
36+
pub fn update(&mut self, input: &crate::player::controller::ControllerInput, delta_time: f32) {
3737
match self.controller.get_action(input) {
3838
MoveUp => {
3939
self.position_y -= RACKET_SPEED * delta_time;

0 commit comments

Comments
 (0)