Skip to content

Latest commit

 

History

History

5-capstone

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

TicTacToe

This is the captone project for the course Udacity C++ Nanodegree Program, option A.

Dependencies for Running Locally

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory in the top level directory: mkdir -p build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./tictactoe

Project Structure

project
│   README.md
│
└─── assets #font/image assets
│   │
│   └─── font # custom font for game
|   │
│   └─── images # game sprites
│
│
└───include # directory for header files
|    │   field.h      # Field class manages state for Player, Cell and the Gameplay
|    │   sprite.h     # Sprite class for handling image assets
|    │   structs.h    # Helper structs used in Field and Sprite classes
|    │   window.h     # Class for drawing board and images on screen using SDL 2.0
│
└─── src # implementation details for classes(detailed explanation below)
│
└───.clang-format
│
└───.gitignore
│
└───CMakeLists.txt
│
└───README.md

Implementation Details

When the game initially launches, window.drawFame() is called inside src/main.cpp. window.cpp defines a class that serves as the entrypoint for our game. It handles window-related details(creating window, loading fonts and sprites, handling mouse/keyboard events). All game state is delegated to the Field class defined in field.cpp. This tracks board state for players, their next moves and whether a player has won or not Sprite class is used to handle game assets. `

Criteria Addressed:

  • The project demonstrates an understanding of C++ functions and control structures. => main.cpp, window.cpp(Window::gameOver)
  • The project accepts user input and processes the input. => window.cpp(Window::processEvents)
  • The project uses Object Oriented Programming techniques. => Field, Window and Sprite classes
  • Classes abstract implementation details from their interfaces. => header files(field.h, sprite.h, window.h) are separated from implementation details
  • The project uses destructors appropriately. => Window class