Skip to content

shivkurtarkar/PacMan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CppND: Pacman game

Pacman game I developed for udacity Cpp Nanodegree capstone project.

Pacman Game gif

Table of Contents

Introduction

Capstone project for Udacity's C++ Nanodegree program consisting on an implementation of the 2D Game Pacman. I used CppND-Capstone-Snake-Game as starter code.

Keyboard Interaction

The user can interact with the game using the following keys:

Key Action
Up move pacman up
Down move pacman down
Right move pacman right
Left move pacman left

Dependencies for Running Locally

Basic Build Instructions

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

Project Files

src/ Source files are in this folder

main.cpp

main.cpp is the entry point for the game. It instaciates Game object, initializes and sets params and starts game by calling run function.

game.h and game.cpp

game.h, game.cpp class handles main game loop. It contains game state as a member which has all state info.

game_impl.h

contains definataion of Game::Run. It is a generic function that takes in generic controller.

gameState.h and gameState.cpp

gameState.h and gameState.cpp Holds all game state info. Intiuition is to seperate out game state so it can be stored or loaded and be used for ai bot controller game as extension later on (future scope). This class has all function defination needed to interact with the state info.

renderer.h and renderer.cpp

renderer.h and renderer.h class is ment to hold all renderer related functions. This class takes Layout class as input, which contains all elements on map and renders it on ui. Elements are walls, food, capsule and agents.

layout.h and layout.cpp

layout.h and layout.cpp contains all elements and thier location on map. Grid class is used to encapsulate and hold info about each cell. It is used to store food data and wall data. Capsule is stored as vector of pair, since they are few This saves space. It also has vector of pointer to all agents, giving access to all agents location. This class also defines map loading funtion to read map data from file. It also defines collide function that handles pacmans collision with other objects(read #pacman section).

agent.h and agent.cpp

agent.h and agent.h This is a base class which encapsulates agents basic info like co-ordinates, type of agent, is alive. It also defines function to move agents. It does this by quering the layout if action is legal or not.

controller.h and controller_impl.h

controller.h and controller_impl.h, Controller class is a generic class that takes an agent as parameter and controlles it. There are 2 controllers defined in here. Controller class handles input by reading keyboard input. While
BotController class gives random input from possible legal moves. More controllers can be defined to use ai to control agents(future scope)

pacman.h and pacman.cpp

pacman.h and pacman.cpp This class inherits from Agent class and defines pacman specific behaviour. It calls collide function on layout class which handles its collission with all other objects on map. This collision function is supposed to handle pacmans consumption of food and capsules and collision with ghosts.

ghost.h andghost.cpp

ghost.h and ghost.cpp class inherits from agent class and defines ghost specific behaviour. It handles logic of if it hits pacman it kills it. But if scare time is running then it dies.

debug.h

layouts/

This folder contains bunch of pacman maps

Testing the implementation

to turn on debug logs change macro in debug.h from #define DEBUG(x) to #define DEBUG(x) x

Rubic Points addressed

below are the rubic pints that are addressed/implemented in this project.

Loops, Functions, I/O

Rubric point Location
The project demonstrates an understanding of C++ functions and control structures. Yes, check all the files
The project reads data from a file and process the data, or the program writes data to a file. Layout
The project accepts user input and processes the input. controller

Object Oriented Programming

Rubric point Location
The project uses Object Oriented Programming techniques. Yes, check all the files
Classes use appropriate access specifiers for class members. Yes, check all the files
Class constructors utilize member initialization lists. Yes, check all the files
Classes abstract implementation details from their interfaces. Yes, check all the files
Classes encapsulate behavior. Yes, check all the files
Classes follow an appropriate inheritance hierarchy. agent, pacman and ghost
Templates generalize functions in the project. game and controller

Memory Management

Rubric point Location
The project makes use of references in function declarations. pacman.cpp Pacman::HandleCollision(GameState& gameState)
The project uses destructors appropriately. layout.cpp Grid class
The project uses scope / Resource Acquisition Is Initialization (RAII) where appropriate. Yes, check all the files

References

https://www.informit.com/articles/article.aspx?p=2928180&seqNum=4

About

Pacman game I developed from scratch for udacity cpp nano degree capstone project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors