Asteroids C++
Summer 2023
I developed the iconic Asteroids game using C++ as a means to enhance my C++ skills and to grasp the Entity-Component-System (ECS) game design pattern, utilizing the EnTT library. Additionally, I employed SFML for rendering the 2D visuals. The game includes the classic Asteroids gameplay and features such as a pause menu, main menu and the ability to save high scores.
Key Features
- Physics: Apply velocity as you would in space and accelerate the player's ship to move forward. Then, simply check for collisions, which are simplified because asteroids are mostly circular shapes, making pure distance sufficient for detection.
- Scene Management: Implemented custom scene management that enables the loading and unloading of multiple scenes independently, with each scene responsible for its own entities and systems. Scenes can also be paused, which skips their systems in updates and all communication is decoupled using events.
- Scoring System: The score is based on the size of the asteroid hit by a bullet. This score is saved to a file as a single high score if it surpasses the current one. In the future, you will have the option to enter a username associated with the high score so that multiple high scores can be saved.
Challenges, solutions and lessons learnt
Scene management initially resulted in a lot of circular dependencies because scenes contained systems and I needed systems to trigger scene management events, such as loading a scene. To address this issue, I decoupled systems from scenes by storing only an ID and actually storing systems in a central system manager. When systems need to trigger scene events, I resolved this by using events through a central event manager.