A 2D platformer prototype built from scratch with Python and Pygame. This project focuses on learn class and loop
-
Custom Physics Engine: Implements gravity, acceleration, and velocity accumulation (
$V_f = V_i + a \times t$ ). - Precise Collision Detection: Uses AABB (Axis-Aligned Bounding Box) logic.
- Axis Separation: Handles X and Y movements independently to allow sliding against walls and perfect landing detection.
- Debug Mode: Visualizes hitboxes (red rectangles) to track player position and collision boundaries.
-
Sprite Handling: Uses
surface.blit()with distinct hitbox management for logical positioning.
The game is currently mapped for AZERTY keyboards (standard in France):
| Action | Key |
|---|---|
| Move Left | Left-arrow |
| Move Right | Right-arrow |
| Jump | SPACE |
| Quit | ESC or Close Window |
Instead of fixed movement, the player is controlled by forces.
- Gravity is applied every frame to the vertical velocity (
velocity_y). - Jumping applies an instantaneous negative force.
- The system uses
dt(delta time) to ensure movement is smooth regardless of the framerate.
# Gravity calculation example
self.velocity_y += self.gravity * dt
self.pos.y += self.velocity_y * dt