Rhythm of Pi is a fast-paced running game where the player overcomes obstacles and collects musical notes in a rhythm synchronized with the digits of π. The game’s uniqueness lies in blending mathematics, AI, and adaptive music to create a dynamic and engaging experience.
- AI-Generated Music: Suno AI dynamically adapts melodies to gameplay.
- Level Generation: A custom neural network analyzes the music and generates levels based on the digits of π.
- Golden Ratio Design: Ensures a visually harmonious experience.
- π-Based Hashing Algorithm: Provides secure data handling.
- Web Integration: Communicates with the server to retrieve and parse JSON data for game elements.
The project follows a clean architecture with modular design, allowing scalability and ease of maintenance. Key design patterns include State Machine, Singleton, Observer, Factory, Decorator, and Web Requests.
Contains all game assets, including scripts, prefabs, and resources.
GameInstaller.cs– Configures and initializes game dependencies using Dependency Injection.
Contains essential services and utilities that power the game.
GameSpeedService.cs– Manages game speed dynamically.ICoroutineRunner.cs– Interface for coroutine execution.IObjectFactory.cs– Interface for object factory pattern.IObjectPool.cs– Interface for object pooling.IPHasher.cs– Secure data hashing algorithm based on π.JsonParser.cs– Parses JSON files fetched from the server.LevelSetUpper.cs– Configures the level based on analyzed music data.NotesPlacer.cs– Places musical notes dynamically during gameplay.ObjectPool.cs– Manages object pool to optimize performance.PlatformPlacer.cs– Places platforms based on the level layout.PlayerAnimationPlayer.cs– Handles player animations.PlayerInput.cs– Manages player input and control.PlayerMover.cs– Controls player movement.PrefabFactory.cs– Implements the Factory pattern to instantiate prefabs.SongManager.cs– Controls music playback and synchronization.WebService.cs– Handles web requests and server communication.
Implements the State Machine pattern to manage game and player states.
GameEndState.cs– Handles game over and restart.GameState.cs– Main gameplay state.GameStateInitializer.cs– Initializes game states.InitState.cs– Initializes the game and loads initial data.
-
PlayerEndState.cs– Handles player end-game logic. -
PlayerInGameState.cs– Manages player behavior during gameplay. -
PlayerInitState.cs– Prepares player for entering the game. -
PlayerStateInitializer.cs– Initializes player states. -
AState.cs– Abstract base state. -
IStateInitializer.cs– Interface for initializing states. -
StateMachine.cs– Core state machine logic.
Contains all UI and game element visual components.
GenerateSongPanelView.cs– Dynamically generates song selection panel.LastPlatform.cs– Handles the last platform during level transition.LastScreenView.cs– Displays end-screen summary.LevelCardView.cs– Displays level information.LevelReloader.cs– Reloads levels dynamically.LineView.cs– Manages the visual representation of the beat line.LoadingView.cs– Displays loading progress.LoginPanelView.cs– Handles login UI and interactions.Note.cs– Represents individual musical notes.NoteUIController.cs– Manages note UI updates.Platform.cs– Defines the platform behavior.Player.cs– Core player logic and attributes.ProgressBar.cs– Displays progress.ResultPanelView.cs– Shows game results.
Handles data structures and communication with the server.
JsonUser.cs– Manages user data parsed from JSON.ServerJsonData.cs– Retrieves and parses JSON data from the server.SongElements.cs– Defines music-related data structures.WebFieldVariant.cs– Defines variant types for web data.
Handles the initial game setup and environment configuration.
ACompletableService.cs– Abstract service for managing asynchronous tasks.Bootstrap.cs– Main entry point to initialize game services.CurrentSongInfoSingleton.cs– Implements Singleton Pattern to store current song information.MenuBootstrap.cs– Sets up the game menu.
- Manages the game and player state transitions smoothly.
- Located in
Scripts/States/.
- Ensures single instances of services like
CurrentSongInfoSingleton. - Located in
Bootstrap/CurrentSongInfoSingleton.cs.
- Notifies UI elements and game logic when changes occur.
- Applied in
PlayerInputandSongManager.
- Used for creating various prefabs dynamically.
PrefabFactory.cshandles this functionality.
- Applied in
PlayerMoverto extend functionality with new features.
- Fetches game data from the server and parses it using
WebService.csandJsonParser.cs.
- Data is retrieved from a remote server via RESTful API.
WebService.cshandles requests and responses.- JSON responses are parsed into relevant data models in
Data/.
- Level Generation: Levels are dynamically generated using a neural network based on the digits of π.
- Adaptive Music: Suno AI analyzes in-game progress and adapts the music accordingly.
- Golden Ratio UI Design: All visual elements align with the golden ratio to ensure balance and beauty.
- Unity 2021.3 or later
- .NET 4.x or higher
- Internet connection to access the server
- Clone the repository:
git clone https://github.com/yourusername/RhythmOfPi.git
- Open the project in Unity.
- Configure server URL in
WebService.cs. - Press Play to start the game!
- Update
LevelSetUpper.csto tweak generation rules. - Modify π-based hashing logic in
IPHasher.csfor encryption.
- Replace audio clips in
Resources/Songs/. - Modify UI prefabs in
Assets/Prefabs/UI/.
- Fork the project.
- Create a new feature branch:
git checkout -b feature/new-feature
- Commit changes:
git commit -m "Add new feature" - Push to branch:
git push origin feature/new-feature
- Open a pull request.
- All user data is securely hashed using a π-based algorithm.
- JSON data is validated and sanitized before use.
- Suno AI for providing adaptive music technology.
- Mathematics and π-inspired design enthusiasts for inspiring the core mechanics.