An interactive, real-time 2D spaceship simulation built with C++ and OpenGL (GLUT). This project demonstrates core computer graphics concepts including 2D transformations, interactive UI rendering, and basic physics/animation.
- Advanced 2D Transformations: Smooth implementation of Translation, Rotation, Scaling (Zoom), and Shearing (Skew) using matrix operations.
- Sci-Fi Responsive UI: Custom-built overlay panels featuring rounded corners, alpha blending, and real-time telemetry updates (Position, Angle, Scale, Shear).
- Dynamic Environment: A continuous, auto-generating starfield background and a glowing celestial body (Moon) using
GL_BLEND. - Weapon System: Directional laser firing mechanics mathematically aligned with the spaceship's current transformation matrix (Rotation & Shearing).
- Responsive Design: The viewport and UI elements dynamically scale and reposition upon window resizing.
INTERACTIVE.SPACESHIP.CONTROLLER.mp4
| Key | Action |
|---|---|
| Up / Down Arrows | Translate Rocket (Y-Axis) |
| Left / Right Arrows | Translate Rocket (X-Axis) |
| A / D | Rotate Rocket (Counter-Clockwise / Clockwise) |
| W / S | Scale / Zoom (In / Out) |
| Q / E | Shear / Skew (Left / Right) |
| SPACE | Fire Laser |
| R | Reset all transformations to default |
| ESC | Exit Program |
- Language: C++
- Graphics Library: OpenGL
- Utility Toolkit: GLUT (OpenGL Utility Toolkit)
- Install the required OpenGL libraries:
sudo apt-get install freeglut3-dev
- Compile the project using
g++:g++ main.cpp -o spaceship -lGL -lGLU -lglut
- Run the executable:
./spaceship
- It is recommended to use an IDE like Code::Blocks or Visual Studio with the GLUT libraries pre-configured.
- Simply add
main.cppto your project, link the OpenGL libraries (opengl32.lib,glu32.lib,glut32.lib), build, and run.
- Main Game Loop: Driven by
glutTimerFuncexecuting at ~30 FPS for smooth animations. - Trigonometry & Physics: Lasers calculate their trajectory using
sin()andcos()of the current rotation angle, adjusted for the shear factor. - UI Rendering: Orthographic projection (
gluOrtho2D) ensures UI elements remain perfectly aligned with the screen boundaries regardless of window size.
- Yusuf Husayn - Yusuf Sayed - Yusuf Ramadan - Yusuf Emad
- Omar Khaled - Yusuf Shaker - Ahmad Yasser - Yehia Khalaf
- Abd El-Rahman Fahmy
Prepared for FCAI Beni-Suef University.