Skip to content

Repository files navigation

Window Master - OpenGL Survival Game

A 2D survival game built with OpenGL and FreeGLUT where players control a white circle character, shoot projectiles at enemy rectangles, and survive in a dynamically resizing window environment.

🎮 Game Overview

Window Master is an arcade-style survival game featuring unique mechanics where the game window itself becomes part of the gameplay. Players must navigate, shoot, and survive while the window dynamically changes size based on their actions.

Key Features

  • Player Character: Control a white circle with a black center
  • Enemy System: Red rotating rectangles that chase the player
  • Projectile Combat: Shoot projectiles toward your mouse cursor
  • Dynamic Window: Window size changes based on projectile impacts
  • Health System: Enemies require 2 hits to destroy and change color when damaged
  • Survival Gameplay: Avoid enemies and window boundaries to stay alive

📸 Gameplay

Gameplay

🎯 Gameplay Mechanics

Player Movement

  • Use WASD keys to move your white circle character
  • Movement speed: 3 pixels per frame
  • Avoid touching enemy rectangles or window boundaries

Combat System

  • Left-click anywhere on the screen to shoot projectiles
  • Projectiles travel from player position toward mouse cursor location
  • Each projectile is a small white circle
  • Enemies require 2 hits to destroy

Enemy Behavior

  • Red rectangles spawn from random edge positions
  • Enemies continuously rotate and move toward the player
  • When hit once, enemies turn yellow (1 health remaining)
  • When destroyed, enemies may spawn 0-2 new enemies
  • Each destroyed enemy gives 1 point

Dynamic Window System

  • Window expands by 25 pixels when projectiles hit right or bottom edges
  • Window gradually contracts over time (1 pixel per frame)
  • Window size changes create strategic gameplay elements

🎮 Controls

Input Action
W Move Up
S Move Down
A Move Left
D Move Right
Left Mouse Click Shoot projectile toward cursor

🏆 Scoring System

  • +1 point for each enemy rectangle destroyed
  • Score is displayed when the game ends
  • Try to survive as long as possible for higher scores

💀 Game Over Conditions

The game ends when:

  1. Player collision: Your circle touches an enemy rectangle
  2. Boundary violation: Player moves outside the window boundaries
  3. A message box displays your final score

🛠️ Technical Details

Built With

  • OpenGL - Graphics rendering
  • FreeGLUT - Window management and input handling
  • C++ - Core programming language
  • Code::Blocks - Development environment

System Requirements

  • Windows operating system
  • OpenGL-compatible graphics card
  • FreeGLUT library installed

🚀 Building and Running

Prerequisites

  1. C++ Compiler (MinGW/GCC recommended)
  2. FreeGLUT library
  3. OpenGL development headers

Build Instructions

Using Code::Blocks

  1. Open Window Master.cbp in Code::Blocks
  2. Ensure FreeGLUT is properly linked in project settings
  3. Build the project (F9)
  4. Run the executable from bin/Debug/Window Master.exe

Command Line Build

g++ -o "Window Master" main.cpp -lfreeglut -lopengl32 -lglu32

Running the Game

  • Execute Window Master.exe from the bin/Debug/ folder
  • Or run directly from Code::Blocks (Ctrl+F10)

🎲 Game Strategy Tips

  1. Stay Mobile: Keep moving to avoid enemy rectangles
  2. Use Window Dynamics: Shoot at edges strategically to expand your play area
  3. Target Damaged Enemies: Focus on yellow (damaged) enemies to clear them quickly
  4. Watch Boundaries: Be aware of the shrinking window size
  5. Control Enemy Spawns: Destroying enemies may spawn more, plan accordingly

🔧 Code Structure

Main Classes

  • tl2a: Projectile class handling movement and collision
  • Rectangles: Enemy class with AI, health, and collision detection
  • Main Functions: Display, input handling, and game loop

Key Features Implementation

  • Collision Detection: Circle-rectangle collision using distance calculations
  • Vector Math: Normalized direction vectors for movement
  • OpenGL Rendering: Custom circle drawing and matrix transformations
  • Game State: Real-time updates at 60 FPS using timer callbacks

🔮 Future Enhancements

  • Add sound effects and background music
  • Implement power-ups and special abilities
  • Create multiple difficulty levels
  • Add high score persistence
  • Implement particle effects for explosions

📝 License

This project is created for educational purposes as part of a Graphics Programming course.

🤝 Contributing

This is an academic project. Feel free to fork and modify for your own learning purposes.


Developed as part of AAST Semester 5 Graphics Programming Course

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages