I decided to make a game called Coz for the Capstone Project. This game is played with 2 players. In addition to traditional game, 2 more difficulty level added as a feature. Players will make moves using mouse and keyboard inputs.
- Classes and source files
- Coz - That is the top level class, processes game logic, input handlers, and graphics
- Gamelogic - This class includes necessary methods to perform error checks, validate player moves, keep state of the game
- Graphics - This class has methods and variables to provide graphical interface for the game. For each state of the game it has different methods to draw related view to the screen.
- Controller - This class is responsible for handling user inputs. The game is mainly based on mouse input but it has definitions for some keystrokes. For example, when 'ESC' is pressed it triggers changing view to main using Coz::setMenu(Coz::MENU)
- Definitions - this is a single header file that contains project wide constant definitions
- Main - in main, all the instances are initialized and their references are passed to the instance method
Coz::run(...)
to start game. After run method returns the game window is destroyed and allocated memory for all other class intances are released.
- README (All Rubric Points REQUIRED)
- Compiling and Testing (All Rubric Points REQUIRED) - Tested build instructions on Ubuntu 20.0 and OS X Catalina
- Loops, Functions, I/O
- The project demonstrates an understanding of C++ functions and control structures. - Considering the definition of Coz::run(...), the game state is managed and processed by an infinite loop and conditional statements (from line: 16). A number of control structure is also located inside Controller class, Controller::HandleInput() (line: 5)
- The project reads data from a file and process the data, or the program writes data to a file. - starting from line 82, Graphics::loadMedia() function performs loading media resources and fonts located in data folder into memory.
- The project accepts user input and processes the input. - starting from line 5, the method Controller::HandleInput determines the target of user inputs regarding to the curret state of the game. for example, if user taps the key "H" defined in line 24, it triggers graphic object to draw help screen.
- Object Oriented Programming
- The project uses Object Oriented Programming techniques. - Depending on the purpose, number of classes are created as stated above in the project structure section.
- Classes use appropriate access specifiers for class members. - considering GameLogic class, starting from line 16 public members such as getters/setters and behavioral methods are declared. private members that keeps states and data are declared after line 63
- Class constructors utilize member initialization lists.
- Graphics class constructor - line 4 initializes all media and fonts.
- Gamelogic - line 6 has no constructor but init() method to use same method to reset the game instead re-initializing the object.
- Classes encapsulate behavior. - line 34 member data is accessed via getter and setter methods.
- Memory Management
- The project makes use of references in function declarations. - line 21 the declaration of Coz::run(GameLogic &gamelogic,Graphics &graphics,Controller &controller), accepts 3 references.
- The project uses destructors appropriately. line 35 the destructor of graphics class calls Graphics::close() which release the whole memory allocated fonts and textures.
- cmake >= 3.7
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
- SDL2 >= 2.0.14 See install instructions
- Linux:
sudo apt-get install libsdl2-dev
- Mac:
brew install sdl
- Windows: How to install SDL on Windows
- Linux:
- SDL_Image >= 1.2.12
- Linux:
apt-get install libsdl2-image-dev
- Mac:
brew install sdl_image
- Windows: see SDL image project wiki
- Linux:
- SDL_ttf >= 2.0.11
- Linux :
apt-get install libsdl2-ttf-dev
- Mac :
brew install sdl_ttf
- Windows : see SDL ttf project wiki
- Linux :
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it: `./Coz.