missile_cmd

missile command graphical c/c++ exercise

0
0
0
Shell
public

logo

Missile Command – C++ OOP Project
Graphical solo game implementation using Raylib to practice object-oriented design.

you will learn c/c++, polymorphism, object-oriented design, polymorphic containers, real-time graphics, and keyboard handling.

splash

You’re implementing a Missile Command work-alike. [Gameplay video] https://www.youtube.com/watch?v=GSkJf8wG-L8

Here is the complete ordered list of steps:

1. Fork my repo and clone it to your work area.  
2. Create a CMake build structure where the build happens in `./build` and all source is under `./src`.  
2a.  make sure it builds for windows and linux
2b.  i gave you a build.sh script to help switching between targets
3. Make sure Raylib is installed and referenced by your CMake file.  
4. Your main program should be `./src/main.cpp`.  
5. In `main`, initialize the screen, create an app run loop that waits for ESC, then clean up.  
6. In the main loop, call your render function.  
7. Inside the render function, divide the work into stubs: `draw_background`, `draw_cities`, `draw_enemies`, `draw_missiles`, `draw_explosions`, `draw_site`, and `draw_hud` (fill them in later).  
8. Implement background, cities, and site; the site (crosshair / targeting reticle) moves with the mouse.  
9. The player has 3-6 cities, each with its own missiles.  
10. The user has 3-6 buttons to press (choose the keys); each button fires a missile from the associated city toward the current position of the site, where it will explode.  
11. Implement firing a missile and `draw_missiles`. If a missile hits an explosion or a city, that missile explodes.  
12. Implement enemies and `draw_enemies`. Enemies are planes that drop missiles heading toward a city. Some missiles splinter into 3–6 other missiles that fan out to new targets.  
12a.  Enemy missiles will also come from 'the sky' at random locations heading to a random city
12b.  Some enemy missiles may target a city that is already gone; but it could also splinter
13. Implement the HUD; show number of lives and score.  
14. Implement levels. A level is defined by the number of enemies destroyed; each level increases the number of enemies, number of missiles, and speed.
15.  Game ends when all cities are destroyed; sped up missile dump; huge explosion

screen1

# Missile Command

C++ project focused on learning object-oriented design through a graphical implementation of the classic solo game *Missile Command*, using the Raylib library.

## Learning Goals
- Practice OOP (classes, encapsulation, composition, polymorphism where useful)
- Structure a real-time game loop
- Manage game entities (missiles, cities, enemies, explosions, site/crosshair)
- Use CMake + Raylib for a clean, portable build

## Requirements
- C++17 (or later)
- CMake 3.15+
- Raylib (installed system-wide or via package manager)
- Git

## Project Structure

missile-command/
├── CMakeLists.txt
├── README.md
├── src/
│   └── main.cpp          # (and additional .cpp / .h files as you grow)
└── build/                # out-of-source build directory

## Setup Steps (follow in order)

1. Fork my GitHub repository named `missile-command` (or similar) and clone it to your local work area.
2. Create a CMake build structure:
   - Source files live under `./src`
   - All builds happen inside `./build` (never pollute the source tree)
3. Install Raylib and reference it correctly from your root `CMakeLists.txt`.
4. Create `./src/main.cpp` as the entry point.
5. In `main`:
   - Initialize the window / screen with Raylib
   - Run the main application loop that continues until ESC is pressed
   - Perform clean-up on exit
6. Inside the main loop, call a dedicated `render()` function every frame.
7. Inside `render()`, call (mostly empty) stubs:
   - `draw_background()`
   - `draw_cities()`
   - `draw_enemies()`
   - `draw_missiles()`
   - `draw_explosions()`
   - `draw_site()`
   - `draw_hud()`
8. Implement background, the three cities, and the site (targeting reticle). The site must follow the mouse cursor.
9. Give the player three cities; each city has its own stock of defensive missiles.
10. Map three keyboard buttons to the three cities. Pressing a button fires a missile from that city toward the current location of the site; the missile travels and then explodes at the target point.
11. Fully implement missile firing and `draw_missiles()`. A missile that collides with an existing explosion or with a city also explodes.
12. Implement enemies (`draw_enemies()`):
    - Planes that fly across the screen and drop missiles aimed at cities
    - Some incoming missiles can splinter into 3–6 new missiles that fan out toward different targets
13. Implement the HUD showing remaining lives and current score.
14. Implement levels:
    - A level ends when a certain number of enemies have been destroyed
    - Each successive level increases the number of enemies, the number of missiles they drop, and their speed

screen2

Building & Running

./build.sh
./build/missile-command   # or the exact executable name you set in CMakeLists.txt

Controls (to be finalized in later steps)

  • Mouse: move the targeting site
  • Three chosen keys: fire from city 1 / city 2 / city 3
  • ESC: quit

Future Extensions (optional after core is working)

  • expand to multi player
  • port it to WASM (requires Emscripten)
  • Sound effects / music
  • Particle improvements for explosions
  • High-score persistence
  • More sophisticated enemy AI / wave patterns

the_end

v0.3.3[beta]