This document provides a comprehensive walkthrough of the OpenGL-based animation project. The goal is to understand the structure, purpose, and flow of each component in the code.
#define STB_IMAGE_IMPLEMENTATION
This macro tells the compiler to include the actual implementation of the stb_image
 library functions. Without this, the header file would only provide function declarations.
#include "stb_image.h"
Includes the STB image library, which is used for loading image files (e.g., PNGs) into memory.
#include <GLUT/glut.h>
This includes the GLUT (OpenGL Utility Toolkit) library. GLUT provides cross-platform support for creating windows, handling input, and managing rendering loops.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
These are standard C libraries for input/output, memory management, mathematical operations, and boolean data types.
GLuint bg1, bg2, rocketTex;
OpenGL texture IDs that store the references for our background and rocket textures.
bool animationStarted = false;
bool rocketMode = false;
bool isPaused = false;
Booleans for controlling animation state: whether it's started, currently showing the rocket, or paused.
int frame = 0;
float ballX = 0.0f;
float ballY = -0.3f;
float ballVelocity = 0.025f;
float gravity = -0.001f;
float rocketY = -0.3f;
int bounceCount = 0;
Physics variables. ballY
 and rocketY
 track vertical positions, while ballVelocity
 and gravity
 simulate motion.
float bgAspect = 1.0f;