Skip to content

Standard Missle command game. Use the mouse to direct defensive missles at enemy missles.

Notifications You must be signed in to change notification settings

patrickjmcgoldrick/Cpp_MissleCommand_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Missle Command Game

for MacOS

Install homebrew first.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

Install cmake

brew install cmake

Install sdl2_image.

brew install sdl2_image

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. Make sure you have libraries SDL2 and SDL2_Image installed.
  3. Make a build directory in the top level directory: mkdir build && cd build
  4. Compile: cmake .. && make
  5. Run it: ./MissleCommand.

Code Write Up

README

Instructions, how to play the game.

Gameplay:
  • The emeny is firing missles at your cities. You must fire missles back to destroy them.
  • Click with the mouse to fire defensive missles at the incoming missles
  • Missles will fire from the surface and explode at the point you clicked. If you can get the incoming missle into the explosion, it will destroy the incoming missle.
  • 25 points for every missle you destroy
  • In the long run, the game will have levels. Bonus points will be awarded at the end of every level, for each city still standing and each missle not used.
Goal:
  • Protect the cities. When your 6 cities are gone, the game is over.

File Structure.

  • Subdirectory 'src' contains all .cpp and .h files.
  • game.cpp runs the game cycle. It's Run method:
    • takes User input, (controller.cpp)
    • updates game elements, (game.cpp Update method calls Update on game objects)
    • cleans up destroyed elements (game.cpp has two cleanup methods to wipe out destroyed objects)
    • then renders the resulting object to the game screen (render.cpp draws objects)

Compiling And Testing

  • The submission must compile and run.

Loops, Functions, I/0

  • Functions and controll structures are there.
  • No External files read.
  • User input is taken from the mouse pointer to aim missles.
    • src/control.cpp - line 7 'HandleInput' reads mouse clicks

Object Oriented Programming

  • All class data members are explicitly specified as public, protected, or private.

    • see missle.h, all lines
  • Classes use accessor functions

  • Class constructors use Member initialization lists

    • game.cpp, in constructor at lines 8-10
    • renderer.cpp, in constructor at lines 8-11
    • controler.cpp, lines 13-14
  • Details abstracted in classes

    • silo.cpp city.cpp missle.cpp
  • Encapsalation

    • silo.cpp city.cpp missle.cpp
  • One member function in an inherited class overrides a virtual base class member function.

    • see missle.h base class with virtual function 'Update' at line 25.
      • offense_missle.h / .cpp at line 6 and
      • defense_missle.h / .cpp at line 10, override 'Update' virtual function.

Memory Management

  • Refernces are passed, specially vectors of shared_ptrs.
    • game.h Game::Run, line 55
  • Uses shared_ptr for Vectors of silo.cpp, city.cpp, offense_missle.cpp, and defense_missle.cpp
    • game.h lines 41-45

Concurrency

Inital starter code from - CPPND: Capstone Snake Game Example

repo

This is a starter repo for the Capstone project in the Udacity C++ Nanodegree Program. The code for this repo was inspired by this excellent StackOverflow post and set of responses.

About

Standard Missle command game. Use the mouse to direct defensive missles at enemy missles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published