u/1xwaterblade

I built an Interactive 2D Spaceship Controller from scratch using C++ and OpenGL. Focused on Object Pooling & Custom Matrix Math! 🚀

Hey everyone,

My team and I recently completed our Computer Graphics final project, and I wanted to share the architecture and source code with this community. It’s a fully interactive, high-performance 2D Spaceship simulation built strictly with C++ and OpenGL.

This project was a massive challenge in applying raw mathematical concepts and physics logic rather than relying on pre-built game engine features.

Here is how we handled the core mechanics:

  • Advanced Matrix Transformations: We applied core concepts of Translation, Rotation, and Scaling manually. We also constructed a custom matrix for Shearing (Skew) to ensure the spaceship mechanics felt smooth and realistic.
  • Performance & Object Pooling: To handle a continuous weapon system (Lasers) without tanking the frame rate, we engineered an Object Pool. This reuses existing memory instead of constantly allocating/deallocating, ensuring zero memory leaks and a stable FPS.
  • Trigonometry & Physics: We integrated Sine, Cosine, and atan2f math functions to calculate precise, real-time laser trajectories based on the spaceship's current transformation matrix.
  • Responsive UI: Designed a custom, Alpha-Blended user interface that dynamically adapts to screen resizing while displaying real-time telemetry data accurately.

It was an incredible collaborative effort with 5 other teammates, and we learned a lot about lower-level graphics programming.

💻 Source Code & Architecture: You can check out the full repo here: GitHub Repo

I would love to hear your thoughts on the codebase, the math implementations, or any feedback on how we could optimize the architecture further!

u/1xwaterblade — 4 days ago