Skip to content

Cata1022/2D-Graphics-Chicken-Invaders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

2D Chicken Invader

About the Project

This project is a 2D arcade-style space shooter. My primary goal in building this project was to explore the fundamentals of 2D computer graphics, game loop architecture, and user interaction using OpenGL all while applying basic OOP principles.

Rather than just building a static game, I wanted to explore dynamic rendering and state management. To achieve this, I implemented an interactive drag-and-drop Spaceship Editor where players can design their own vehicle before the gameplay begins. The custom ship is then loaded and rendered into the game engine.

Technical Takeaways & What I Learned

Building this game from scratch using OpenGL was a great hands-on experience with lower-level graphics programming. Key areas I focused on include:

  • 2D Rendering & Primitives: I learned how to construct complex visual elements (ships, enemies, projectiles, UI components) by combining basic OpenGL geometric primitives (quads, triangles, circles/semi-circles). I assigned distinct colors and vertices to different block types (e.g., thrusters, cannons) to make them visually distinct.
  • Coordinate Systems & Transformations: I gained a solid understanding of mapping screen coordinates to world coordinates, utilizing translation, scaling, and rotation matrices to animate enemies and move the player's ship.
  • State Management & Game Loop: I implemented a robust game state machine to transition between the UI/Editor state and the active Gameplay state.
  • Algorithmic Validation: To ensure the custom ship was valid, I applied graph traversal algorithms (checking if the ship blocks are contiguous/connected) and spatial constraints (e.g., ensuring cannons aren't blocked, engines are placed at the bottom, and the block limit is respected).
  • Collision Detection: I implemented mathematical collision detection algorithms, approximating enemies with bounding circles and projectiles with points/rectangles to handle hits.

Core Features

1. Interactive Spaceship Editor

Before the action starts, the player uses a grid-based visual editor to design their ship.

  • Drag and Drop Interface: Implemented custom mouse-picking logic. Players can click, drag, and drop different functional blocks (Solid, Cannon, Engine) onto a 2D grid.
  • Dynamic Validation: The editor runs real-time checks. The "Start" button only turns green if the ship is structurally sound (contiguous blocks, maximum 10 components, logical placement of engines and weapons).
  • Right-Click Deletion: Added intuitive controls to remove blocks and free up the component budget.

2. Dynamic Gameplay Mechanics

Once the ship is validated, the game engine imports the player's custom design.

  • Stat Scaling: The design of the ship actively impacts the game. For example, the movement speed of the player's ship dynamically scales based on the number of "Engine" blocks they placed in the editor.
  • Shoot 'em Up Action: The player navigates the custom ship across the screen, dodging enemy fire and shooting projectiles from the specific locations where they placed their "Cannon" blocks.

3. Enemy Waves

  • Sinusoidal Movement: Instead of static downward movement, enemies follow smooth, sinusoidal paths as they descend, making them harder to hit.
  • Progressive Difficulty (Wave System): Once the screen is cleared, a new wave of enemies spawns after a short delay. Each wave increases in difficulty—enemies move faster, shoot more frequently, and fire faster projectiles.
  • Win/Loss Conditions: The player loses if they are hit by an enemy projectile or if any enemy successfully breaches the bottom edge of the screen.

About

2D arcade space shooter using OpenGL to explore lower-level graphics programming, rendering pipelines, and game state management

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors