Sun Rider
Multi-purpose View the repo
13 stars · 2 forks
- Maintainer
- treblewolf
- Chip families
- esp32-s3
Runs on these boards
Unverified
- CardputerUnverified
Flash Cardputer
Unverified esp-atlas asserts this board↔firmware link at the shown trust tier — it does not guarantee your specific unit or the current firmware version. Flashing can erase keys/config and can brick the device. At your own risk.
README
☀️ Sun Rider for M5Stack Cardputer ☀️
A 2D physics-based side-scrolling driving game with procedurally generated terrain.
-
An alien has depleted his magic goo fuel, and now has to use petrol like a real man. Unfortunately the fumes got the best of him and now he's on an endless voyage to get sober.🌌
-
Available in M5Burner and M5Launcher!
Features
-
⚙️ Custom Physics Engine:
- Simulates a chassis and two wheels connected by suspension.
- Includes gravity, drive torque, leaning torque, suspension forces, friction, and air resistance.
- Uses physics sub-stepping for improved stability.
- Handles collisions between the vehicle, rider, and terrain.
-
🏞️ Procedural Terrain:
- Endless, varied landscape generated on-the-fly using line segments.
- Checkpoints mark distance milestones.
-
🖼️ Dynamic Backgrounds:
- Parallax scrolling Starfield, Nebula, and Meteor Shower effects.
- Smooth transitions between background types based on distance traveled.
-
🎨 Graphics & Rendering:
- Utilizes the M5GFX library via the M5Cardputer library.
- Renders to an off-screen buffer for smooth, flicker-free animation.
- Rotating sprites for the vehicle and rider.
- Particle system for wheel dirt effects.
-
🎮 Gameplay & UI:
- Simple controls for acceleration and leaning.
- Game over on crashing or falling.
- Tracks total distance and saves the high score.
- Configurable on-screen display for FPS and distance.
- Main Menu and detailed Options Menu.
-
💾 Options & Persistence:
- Adjustable settings: Brightness, Volume, Gravity, Torque, Info Corner, Smooth Camera, Terrain Color, Menu Background.
- Settings and high score saved persistently using the Preferences library.
-
🔊 Audio:
- Simple synthesized sound effects for engine, menus, game over, and high score.
Gameplay & Controls ⌨️
- Objective: Drive as far as possible without crashing.
- Controls (Default Keyboard):
Space: AccelerateA: Lean LeftD: Lean Right- Menus:
Up Arrow: Navigate UpDown Arrow: Navigate DownLeft Arrow: Decrease Value (in Options)Right Arrow: Increase Value (in Options)Space: Select / ConfirmEsc: Back (from Options)
🛠️ Building & Installation
This project is designed for the M5Stack Cardputer.
- Prerequisites:
- Arduino IDE or PlatformIO installed. 💻
- M5Stack Board definitions installed for your IDE.
- M5Cardputer Library installed. (This library includes the necessary M5GFX dependency). 📚
- Clone the Repository:
git clone https://github.com/Treblewolf/M5Cardputer-Sun-Rider.git cd M5Cardputer-Sun-Rider - ⚡ Build & Upload:
- Arduino IDE:
- Open the
.inofile, select the correct M5Stack Cardputer board from the Tools menu, go toSketchandExport Compiled Binary - Copy the compiled
.binfile onto SD card and run through M5Launcher
💡 Technical Highlights
- Vec2D Struct: Custom 2D vector implementation for physics calculations.
- State Machine: Simple
enum GameStatemanages game flow. - Scrolling Options Menu: Handles more options than fit on the screen.
- Smooth Camera: Toggable camera smoothing for player following. 🎥
- Color Fading/Blending: Helper functions for visual effects.
- Sprite Rendering: Uses
pushImageRotateZoomWithAAfor anti-aliased rotated sprites. - Background Management: Intelligent wrapping and resetting of background elements.
🙌Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
📄 License
Distributed under the MIT License. See LICENSE file for more information.
Read the full README on GitHub
source github.com/Treblewolf/M5Cardputer-Sun-Rider