diff --git a/src/AppState.hpp b/src/AppState.hpp index 10ed61c..10e9af3 100644 --- a/src/AppState.hpp +++ b/src/AppState.hpp @@ -10,8 +10,13 @@ namespace chesspp class AppState : public SFMLEvent { public: - AppState(sf::RenderWindow *_display) : display(_display) {} - virtual ~AppState() {} + AppState(sf::RenderWindow *_display) + : display(_display) + { + } + virtual ~AppState() + { + } virtual int id() = 0; virtual void OnRender() = 0; diff --git a/src/AppStateGame.cpp b/src/AppStateGame.cpp index c4a4b66..b2552a2 100644 --- a/src/AppStateGame.cpp +++ b/src/AppStateGame.cpp @@ -2,34 +2,37 @@ namespace chesspp { - AppStateGame::AppStateGame( Application*_app, sf::RenderWindow *_display ) - : AppState(_display) - , app(_app) - , graphics(display) + AppStateGame::AppStateGame(Application *_app, sf::RenderWindow *_display) + : AppState(_display) + , app(_app) + , graphics(display) { board = new board::Board(); board->newGame(boardConfig.getInitialLayout()); } - int AppStateGame::id() { return 1; } + int AppStateGame::id() + { + return 1; + } void AppStateGame::OnRender() { graphics.drawBoard(board); } - void AppStateGame::OnLButtonPressed(int x, int y) + void AppStateGame::OnLButtonPressed(int x, int y) noexcept { - board->setSelected(board->getCurrent()); // No matter if NULL + board->setSelected(board->getCurrent()); //No matter if nullptr } - void AppStateGame::OnMouseMoved(int x, int y) + void AppStateGame::OnMouseMoved(int x, int y) noexcept { - board->setCurrent(x,y); + board->setCurrent(x, y); } - void AppStateGame::OnLButtonReleased(int x, int y) + void AppStateGame::OnLButtonReleased(int x, int y) noexcept { - // board knows what is selected, but I think this looks more clear + //board knows what is selected, but I think this looks more clear board->move(board->getSelected(), x, y); - board->setSelected(NULL); + board->setSelected(nullptr); } } diff --git a/src/AppStateGame.hpp b/src/AppStateGame.hpp index ed708d6..f375866 100644 --- a/src/AppStateGame.hpp +++ b/src/AppStateGame.hpp @@ -12,22 +12,24 @@ namespace chesspp class Application; class AppStateGame : public AppState { - Application*app; - board::Board*board; + Application *app; + board::Board *board; graphics::GraphicsHandler graphics; config::BoardConfig boardConfig; public: - AppStateGame(Application*_app, sf::RenderWindow *_display); - virtual ~AppStateGame() {} + AppStateGame(Application *_app, sf::RenderWindow *_display); + virtual ~AppStateGame() + { + } virtual int id(); virtual void OnRender(); - virtual void OnLButtonPressed(int x, int y); - virtual void OnLButtonReleased(int x, int y); - virtual void OnMouseMoved(int x, int y); + virtual void OnLButtonPressed(int x, int y) noexcept; + virtual void OnLButtonReleased(int x, int y) noexcept; + virtual void OnMouseMoved(int x, int y) noexcept; }; } diff --git a/src/Application.cpp b/src/Application.cpp index ca379b9..6f26ae2 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -4,9 +4,9 @@ namespace chesspp { Application::Application() - : display(sf::VideoMode(640, 640), "ChessPlusPlus", sf::Style::Close), - running(true), - state(new AppStateGame(this, &display)) + : display(sf::VideoMode(640, 640), "ChessPlusPlus", sf::Style::Close) + , running(true) + , state(new AppStateGame(this, &display)) { display.setVerticalSyncEnabled(true); } @@ -17,7 +17,9 @@ namespace chesspp while(running) { while(display.pollEvent(Event)) + { OnEvent(&Event); + } state->OnRender(); display.display(); @@ -28,7 +30,7 @@ namespace chesspp Application::~Application() { - delete state; //Even if it's null, no matter. + delete state; } void Application::OnEvent(sf::Event *Event) diff --git a/src/Application.hpp b/src/Application.hpp index d7214fa..17f7495 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -9,14 +9,15 @@ namespace chesspp { sf::RenderWindow display; bool running; - AppState*state; + AppState *state; void OnEvent(sf::Event *Event); public: Application(); ~Application(); - template void ChangeState() + template + void ChangeState() { delete state; state = new NewState; diff --git a/src/Debug.hpp b/src/Debug.hpp index 414365e..82cda1d 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -6,14 +6,25 @@ #include class LogUtil //replaces std::clog, std::cerr, std::cout with file streams -{ //should eventually convert to singleton +{ std::ofstream log {"debug_log.log", std::ios::out|std::ios::trunc} , err {"debug_err.log", std::ios::out|std::ios::trunc} , out {"debug_out.log", std::ios::out|std::ios::trunc}; std::streambuf *clogbuf {log ? std::clog.rdbuf(log.rdbuf()) : std::clog.rdbuf()} , *cerrbuf {err ? std::cerr.rdbuf(err.rdbuf()) : std::cerr.rdbuf()} , *coutbuf {out ? std::cout.rdbuf(out.rdbuf()) : std::cout.rdbuf()}; + LogUtil() noexcept + { + } + LogUtil(LogUtil const &) = delete; + LogUtil(LogUtil &&) = delete; + LogUtil &operator=(LogUtil const &) = delete; + LogUtil &operator=(LogUtil &&) = delete; public: + static void EnableRedirection() noexcept + { + static LogUtil lu; + } ~LogUtil() noexcept { std::clog.rdbuf(clogbuf), clogbuf = nullptr; diff --git a/src/Main.cpp b/src/Main.cpp index c6824f5..5aa9969 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -9,7 +9,7 @@ int main() { - LogUtil lu; //replaces std::clog, std::cerr, std::cout with file streams + LogUtil::EnableRedirection(); try { diff --git a/src/ResourceManager.hpp b/src/ResourceManager.hpp index d7e7663..235eb84 100644 --- a/src/ResourceManager.hpp +++ b/src/ResourceManager.hpp @@ -7,67 +7,59 @@ namespace chesspp { - template > + template> class ResourceManager { - private: //no copying - ResourceManager(const ResourceManager&); - ResourceManager &operator=(const ResourceManager&); + ResourceManager(ResourceManager const &) = delete; + ResourceManager &operator=(ResourceManager const &) = delete; - private: - typedef std::unique_ptr ptr_t; - typedef typename std::map map_t; - typedef typename map_t::iterator map_i; + using ptr_t = std::unique_ptr; + using map_t = typename std::map; + using map_i = typename map_t::iterator; + + map_t m_map; //resource map protected: - inline ResourceManager() {} - inline ~ResourceManager() {} + ResourceManager() noexcept + { + } + ~ResourceManager() noexcept + { + } //pure virtual, defined depending on what is being loaded. - virtual T *onLoadResource(const key_type &key) = 0; + virtual T *onLoadResource(key_type const &key) noexcept = 0; public: - //************************************ - // Method: Free - // FullName: ResourceManager::Free - // Access: public - // Returns: void - // Parameter: const std::string &key - // Deletes the entry of a key in the resource map. - // This will call deleter_type to deallocate the resource from memory as well. - //************************************ - void Free(const key_type &key) { + //Deletes the entry of a key in the resource map. + //This will call deleter_type to deallocate the resource from memory as well. + void Free(key_type const &key) noexcept + { map_i i = m_map.find(key); m_map.erase(i); } - //************************************ - // Method: Load - // FullName: ResourceManager::Load - // Access: public - // Returns: ptr_t - // Parameter: const std::string &key - // Returns a reference to the resource associated with the file name 'key' if it exists in memory. - // Otherwise it loads the texture into memory, and returns a reference to the the resource. - //************************************ - T &Load(const std::string &key) + //Returns a reference to the resource associated with the file name 'key' if it exists in memory. + //Otherwise it loads the texture into memory, and returns a reference to the the resource. + T &Load(key_type const &key) noexcept(false) { map_i i = m_map.find(key); if(i != m_map.end()) + { return *i->second.get(); //return resource if exists + } //else, load resource - ptr_t p(onLoadResource(key)); + ptr_t p {onLoadResource(key)}; if(p.get() == NULL) - throw Exception("Error loading Image at " + key); //figure out better way to throw exceptions later + { + throw Exception(std::string("Error loading Image at ") + key); + } m_map.insert(std::make_pair(key, std::move(p))); return *m_map[key].get(); } - - private: - map_t m_map; //resource map }; } diff --git a/src/SFML.hpp b/src/SFML.hpp index 9804df0..f07d4f1 100644 --- a/src/SFML.hpp +++ b/src/SFML.hpp @@ -3,7 +3,7 @@ #define SFMLFULL_INCLUDED #include -#include +#include //\ #include #include #include diff --git a/src/SFMLEvent.hpp b/src/SFMLEvent.hpp index 091563c..b04666b 100644 --- a/src/SFMLEvent.hpp +++ b/src/SFMLEvent.hpp @@ -8,31 +8,35 @@ namespace chesspp class SFMLEvent { public: - typedef unsigned int uint; - virtual void OnClosed() {} - virtual void OnResized(uint w, uint h) {} - virtual void OnLostFocus() {} - virtual void OnGainedFocus() {} - virtual void OnTextEntered(sf::Uint32 unicode) {} - virtual void OnKeyPressed(sf::Keyboard::Key key, bool alt, bool control, bool shift, bool system) {} - virtual void OnKeyReleased(sf::Keyboard::Key key, bool alt, bool control, bool shift, bool system) {} - virtual void OnMouseWheelMoved(int delta, int x, int y) {} - virtual void OnLButtonPressed(int x, int y) {} - virtual void OnLButtonReleased(int x, int y) {} - virtual void OnRButtonPressed(int x, int y) {} - virtual void OnRButtonReleased(int x, int y) {} - virtual void OnMButtonPressed(int x, int y) {} - virtual void OnMButtonReleased(int x, int y) {} - virtual void OnMouseButtonPressed(sf::Mouse::Button button, int x, int y) {} - virtual void OnMouseButtonReleased(sf::Mouse::Button button, int x, int y) {} - virtual void OnMouseMoved(int x, int y) {} - virtual void OnMouseEnteredWindow() {} - virtual void OnMouseLeftWindow() {} - virtual void OnJoystickButtonPressed(uint joystickID, uint button) {} - virtual void OnJoystickButtonReleased(uint joystickID, uint button) {} - virtual void OnJoystickMoved(uint joystickID, sf::Joystick::Axis axis, float position) {} - virtual void OnJoystickConnected(uint joystickID) {} - virtual void OnJoystickDisconnected(uint joystickID) {} + using uint = unsigned int; + virtual void OnClosed () noexcept {} + virtual void OnResized (uint w, uint h) noexcept {} + virtual void OnLostFocus () noexcept {} + virtual void OnGainedFocus () noexcept {} + virtual void OnTextEntered (sf::Uint32 unicode) noexcept {} + virtual void OnKeyPressed (sf::Keyboard::Key key, bool alt, bool control, bool shift, bool system) noexcept {} + virtual void OnKeyReleased (sf::Keyboard::Key key, bool alt, bool control, bool shift, bool system) noexcept {} + virtual void OnMouseWheelMoved (int delta, int x, int y) noexcept {} + virtual void OnLButtonPressed (int x, int y) noexcept {} + virtual void OnLButtonReleased (int x, int y) noexcept {} + virtual void OnRButtonPressed (int x, int y) noexcept {} + virtual void OnRButtonReleased (int x, int y) noexcept {} + virtual void OnMButtonPressed (int x, int y) noexcept {} + virtual void OnMButtonReleased (int x, int y) noexcept {} + virtual void OnMouseButtonPressed (sf::Mouse::Button button, int x, int y) noexcept {} + virtual void OnMouseButtonReleased (sf::Mouse::Button button, int x, int y) noexcept {} + virtual void OnMouseMoved (int x, int y) noexcept {} + virtual void OnMouseEnteredWindow () noexcept {} + virtual void OnMouseLeftWindow () noexcept {} + virtual void OnJoystickButtonPressed (uint joystickID, uint button) noexcept {} + virtual void OnJoystickButtonReleased(uint joystickID, uint button) noexcept {} + virtual void OnJoystickMoved (uint joystickID, sf::Joystick::Axis axis, float position) noexcept {} + virtual void OnJoystickConnected (uint joystickID) noexcept {} + virtual void OnJoystickDisconnected (uint joystickID) noexcept {} + + virtual ~SFMLEvent() noexcept + { + } }; } diff --git a/src/TextureManager.hpp b/src/TextureManager.hpp index 64e7cdc..f7d5f63 100644 --- a/src/TextureManager.hpp +++ b/src/TextureManager.hpp @@ -1,66 +1,54 @@ #ifndef _TEXTUREMANAGER_H #define _TEXTUREMANAGER_H + +#include + #include "ResourceManager.hpp" #include "SFML.hpp" + namespace chesspp { struct TextureDeleter { - //************************************ - // Method: operator() - // FullName: TextureDeleter::operator() - // Access: public - // Returns: void - // Parameter: sf::Texture *texture - // Structure used by std::shared_ptr to delete an sf::Texture. - // This isn't needed because std::default_delete does the same thing. - // Using it for debugging purposes, though. - //************************************ - void operator()(sf::Texture *texture) + //Structure used by std::shared_ptr to delete an sf::Texture. + //This isn't needed because std::default_delete does the same thing. + //Using it for debugging purposes, though. + void operator()(sf::Texture *texture) noexcept { -#ifdef _DEBUG - cout << "Deleting texture - unique_ptr has been deleted." << endl; -#endif + std::clog << "Deleting texture - unique_ptr has been deleted." << std::endl; delete texture; } }; class TextureManager : public ResourceManager { - private: - inline TextureManager() {} + TextureManager() noexcept + { + } //no copying - TextureManager(const TextureManager &); - TextureManager &operator=(const TextureManager &); + TextureManager(const TextureManager &) = delete; + TextureManager &operator=(const TextureManager &) = delete; public: - static TextureManager &getInstance() //singleton class + static TextureManager &getInstance() noexcept //singleton class { static TextureManager instance; return instance; } protected: - //************************************ - // Method: onLoadResource - // FullName: TextureManager::onLoadResource - // Access: protected - // Returns: sf::Texture * - // Parameter: const std::string &location - // Method that loads an sf::Texture from file name 'location'. - //************************************ - virtual sf::Texture *onLoadResource(const std::string &location) + //Method that loads an sf::Texture from file name 'location'. + virtual sf::Texture *onLoadResource(const std::string &location) noexcept { sf::Texture *ret = new sf::Texture(); if(!ret->loadFromFile(location)) - return NULL; - -#ifdef _DEBUG - cout << "Loaded " << location << " into memory." << endl; -#endif - + { + std::clog << "Failed to load " << location << std::endl; + return nullptr; + } + std::clog << "Loaded " << location << " into memory." << std::endl; return ret; } }; diff --git a/src/board/Bishop.cpp b/src/board/Bishop.cpp index 44af951..8f4d706 100644 --- a/src/board/Bishop.cpp +++ b/src/board/Bishop.cpp @@ -6,12 +6,12 @@ namespace chesspp { namespace board { - Bishop::Bishop(const Position&bPos, Color c) - : Piece(bPos, Position(80 *3,0), c, Type::BISHOP) + Bishop::Bishop(Position const &bPos, Color c) + : Piece(bPos, Position(80*3, 0), c, Type::BISHOP) { } - void Bishop::makeTrajectory(const Board*board) + void Bishop::makeTrajectory(Board const *board) { std::clog << "BISHOP: " << this->boardPos << " makeTrajectory" << std::endl; diff --git a/src/board/Bishop.hpp b/src/board/Bishop.hpp index 35cdf23..aa8b17f 100644 --- a/src/board/Bishop.hpp +++ b/src/board/Bishop.hpp @@ -14,11 +14,10 @@ namespace chesspp { class Bishop : public Piece { - private: public: - Bishop(const Position&bPos, Color c); + Bishop(Position const &bPos, Color c); - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); }; } } diff --git a/src/board/Board.cpp b/src/board/Board.cpp index a2c5732..f2a31e6 100644 --- a/src/board/Board.cpp +++ b/src/board/Board.cpp @@ -2,38 +2,34 @@ #include +#include "util/Utilities.hpp" + namespace chesspp { namespace board { - Board::Board(void) - :pieces(WIDTH *WIDTH), // WIDTH comes from Position.h - currentPiece(NULL), - selectedPiece(NULL) + Board::Board() + : pieces(WIDTH*WIDTH) { - // I think the initiator did this anyway - for (PieceList::iterator iter = pieces.begin(); iter!=pieces.end(); iter++) - *iter = NULL; } - Board::~Board(void) + Board::~Board() noexcept { resetBoard(); // This deletes the pointers } - void Board::resetBoard(void) + void Board::resetBoard() { - for (PieceList::iterator iter = pieces.begin(); iter!=pieces.end(); iter++) + for(auto iter = pieces.begin(); iter!=pieces.end(); ++iter) { - delete *iter; - *iter = NULL; + delete *iter, *iter = nullptr; } } - bool Board::newGame(const std::string&fileName) + bool Board::newGame(std::string const &fileName) { std::ifstream in(fileName); - if (!in) + if(!in) { std::clog << "Could not open: " + fileName << std::endl; return false; @@ -44,13 +40,13 @@ namespace chesspp // I guess this should happen after the file is opened this->resetBoard(); - char ch; // To read from the file - PieceList::iterator iter = pieces.begin(); // To iterate :) - int pos = 0; // To hopefully count 64 chars + char ch; // To read from the file + auto iter = pieces.begin(); // To iterate :) + int pos = 0; // To hopefully count 64 chars - while (in >> ch) + while(in >> ch) { - if (iter == pieces.end()) + if(iter == pieces.end()) { std::clog << "End of PieceList found before end of file" << std::endl; return false; @@ -58,21 +54,21 @@ namespace chesspp switch(ch) { - case'P':*iter=new Pawn( Position( pos%WIDTH, pos/WIDTH), WHITE);break; - case'R':*iter=new Rook( Position( pos%WIDTH, pos/WIDTH), WHITE);break; - case'N':*iter=new Knight(Position( pos%WIDTH, pos/WIDTH), WHITE);break; - case'B':*iter=new Bishop(Position( pos%WIDTH, pos/WIDTH), WHITE);break; - case'Q':*iter=new Queen( Position( pos%WIDTH, pos/WIDTH), WHITE);break; - case'K':*iter=new King( Position( pos%WIDTH, pos/WIDTH), WHITE);break; - - case'p':*iter=new Pawn( Position( pos%WIDTH, pos/WIDTH), BLACK);break; - case'r':*iter=new Rook( Position( pos%WIDTH, pos/WIDTH), BLACK);break; - case'n':*iter=new Knight(Position( pos%WIDTH, pos/WIDTH), BLACK);break; - case'b':*iter=new Bishop(Position( pos%WIDTH, pos/WIDTH), BLACK);break; - case'q':*iter=new Queen( Position( pos%WIDTH, pos/WIDTH), BLACK);break; - case'k':*iter=new King( Position( pos%WIDTH, pos/WIDTH), BLACK);break; - - case '*': /*No Piece Character */ break; + case 'P':*iter=new Pawn (Position(pos%WIDTH, pos/WIDTH), WHITE); break; + case 'R':*iter=new Rook (Position(pos%WIDTH, pos/WIDTH), WHITE); break; + case 'N':*iter=new Knight(Position(pos%WIDTH, pos/WIDTH), WHITE); break; + case 'B':*iter=new Bishop(Position(pos%WIDTH, pos/WIDTH), WHITE); break; + case 'Q':*iter=new Queen (Position(pos%WIDTH, pos/WIDTH), WHITE); break; + case 'K':*iter=new King (Position(pos%WIDTH, pos/WIDTH), WHITE); break; + + case 'p':*iter=new Pawn (Position(pos%WIDTH, pos/WIDTH), BLACK); break; + case 'r':*iter=new Rook (Position(pos%WIDTH, pos/WIDTH), BLACK); break; + case 'n':*iter=new Knight(Position(pos%WIDTH, pos/WIDTH), BLACK); break; + case 'b':*iter=new Bishop(Position(pos%WIDTH, pos/WIDTH), BLACK); break; + case 'q':*iter=new Queen (Position(pos%WIDTH, pos/WIDTH), BLACK); break; + case 'k':*iter=new King (Position(pos%WIDTH, pos/WIDTH), BLACK); break; + + case '*': break; default: std::clog << "Invalid character found in new_game.txt" << std::endl; @@ -82,9 +78,8 @@ namespace chesspp ++pos; } - if (pos == 64) std::clog << "File size matched pieces size" << std::endl; - else std::clog << "File size did not match pieces size" << std::endl; - + if(pos == 64) std::clog << "File size matched pieces size" << std::endl; + else std::clog << "File size did not match pieces size" << std::endl; in.close(); @@ -93,28 +88,29 @@ namespace chesspp // So the other color can respond to things that may have cuased check // It should be its own function, as it is needed in move() also. - for (PieceList::iterator iter = pieces.begin(); iter!=pieces.end(); iter++) + for(auto iter = pieces.begin(); iter!=pieces.end(); ++iter) { - if (!*iter) continue; + if(!*iter) continue; (*iter)->makeTrajectory(this); } return true; } - int Board::posToInt(const Position&pos) const + int Board::posToInt(Position const &pos) const { - // WIDTH defined in Position.h as 8 - return pos.getY() *WIDTH + pos.getX(); + return pos.getY()*WIDTH + pos.getX(); } - bool Board::hasPosition(const Position&pos) const + bool Board::hasPosition(Position const &pos) const { - return pos.inBounds() &&pieces.at(posToInt(pos)) != NULL; + return pos.inBounds() &&pieces.at(posToInt(pos)) != nullptr; } - Piece*Board::at(const Position&pos) const + Piece*Board::at(Position const &pos) const { - if (!pos.inBounds()) - return NULL; + if(!pos.inBounds()) + { + return nullptr; + } return pieces.at(posToInt(pos)); } @@ -122,50 +118,58 @@ namespace chesspp { static const int SIZE = 80; // The pixel count of a square unsigned int idx = (screenY / SIZE) *WIDTH + (screenX / SIZE); - if (idx >= pieces.size()) - currentPiece = NULL; + if(idx >= pieces.size()) + { + currentPiece = nullptr; + } else + { currentPiece = pieces.at(idx); + } } - Piece*Board::getCurrent(void) const + Piece*Board::getCurrent() const { return currentPiece; } - void Board::setSelected(Piece*toSelect) + void Board::setSelected(Piece *toSelect) { selectedPiece = toSelect; } - Piece*Board::getSelected(void) const + Piece*Board::getSelected() const { return selectedPiece; } - bool Board::move(Piece*toMove, int screenX, int screenY) + bool Board::move(Piece *toMove, int screenX, int screenY) { - // Is the piece NULL - if (!toMove) + // Is the piece nullptr + if(!toMove) { - std::cout << "BM: called With Null" << std::endl; + std::cout << "BM: called With nullptr" << std::endl; return false; } // Is the piece in my list bool inList = false; - for (PieceList::iterator iter = pieces.begin(); iter != pieces.end(); iter++) - if (*iter == toMove) // Memory addresses + for(auto iter = pieces.begin(); iter != pieces.end(); ++iter) + { + if(*iter == toMove) // Memory addresses + { inList = true; - if (!inList) + } + } + if(!inList) { std::clog << "BM: Piece not Found" << std::endl; return false; } // Is the new position on the board? - static const int SIZE = 80; // Really need to define 80 somewhere + static int const SIZE = 80; // Really need to define 80 somewhere int xPos = screenX / SIZE; int yPos = screenY / SIZE; Position moveTo(xPos, yPos); - if (!moveTo.inBounds()) + if(!moveTo.inBounds()) { std::clog << "BM: Position out of bounds" << std::endl; return false; @@ -178,14 +182,14 @@ namespace chesspp // Try to move the piece // This will return false if moveTo isn't in the piece's trajectory // (moveTo would also have to be valid in the trajectory, OnValidity.txt - if (!toMove->move(moveTo)) + if(!toMove->move(moveTo)) { std::clog << "BM: Couldn't move piece" << std::endl; return false; } // Is something very wrong? did Piece::move() actually fail? - if (toMove->getBoardPos() != moveTo) + if(toMove->getBoardPos() != moveTo) { std::clog << "BM: Move didn't really work" << std::endl; return false; @@ -194,7 +198,7 @@ namespace chesspp // If this is a capture int idxTo = posToInt(moveTo); - if (pieces.at(idxTo)) + if(pieces.at(idxTo)) { std::clog << "BM: Capturing piece: " << *pieces.at(idxTo) << std::endl; @@ -206,16 +210,16 @@ namespace chesspp // Move the piece on the board pieces.at(idxTo) = pieces.at(idxFrom); - pieces.at(idxFrom) = NULL; + pieces.at(idxFrom) = nullptr; // Recalcaulte trajectories // The piece that just moved certainly needs this pieces.at(idxTo)->makeTrajectory(this); - for (PieceList::iterator iter = pieces.begin(); iter != pieces.end(); iter++) + for(auto iter = pieces.begin(); iter != pieces.end(); ++iter) { - if (!*iter || *iter == pieces.at(idxTo)) continue; + if(!*iter || *iter == pieces.at(idxTo)) continue; // updateTrajectory checks if moveFrom or moveTo // are in the piece's trajectory @@ -223,7 +227,7 @@ namespace chesspp (*iter)->updateTrajectory(this, moveFrom, moveTo); } - this->currentPiece = NULL; //reset currentPiece to avoid segfault. + this->currentPiece = nullptr; //reset currentPiece to avoid segfault. return true; } } diff --git a/src/board/Board.hpp b/src/board/Board.hpp index 1a56671..083d4e2 100644 --- a/src/board/Board.hpp +++ b/src/board/Board.hpp @@ -23,7 +23,7 @@ namespace chesspp { namespace board { - using PieceList = std::vector; + using PieceList = std::vector; class Board { @@ -31,13 +31,13 @@ namespace chesspp // Deletes all pointers and sets to NULL // Also called during destruction - void resetBoard(void); + void resetBoard(); // Not currently used // The idea is to convert screenX and screenY to a valid idx - // and then return the Piece*found int pieces[idx] + // and then return the Piece * found int pieces[idx] // The code to do this is pretty simple though - Piece*screenToPiece(int screenX, int screenY); + Piece *screenToPiece(int screenX, int screenY); public: // The container to hold the Piece* @@ -47,38 +47,38 @@ namespace chesspp // These two are for user interface // A mouse over changes the current piece (which is allowed to be NULL) // A mouse click on a non-NULL piece will set the selected piece - Piece*currentPiece; - Piece*selectedPiece; + Piece *currentPiece = nullptr; + Piece *selectedPiece = nullptr; - Board(void); // Set up the pieces - ~Board(void); // Delete the pointers in pieces + Board(); + ~Board() noexcept; // Loads the game from new_game.txt - bool newGame(const std::string&fileName); + bool newGame(std::string const &fileName); // Given a Position return the corresponding pieces idx - int posToInt(const Position&pos) const; + int posToInt(Position const &pos) const; // Returns true if pos is in bounds and pieces[pos] is not NULL - bool hasPosition(const Position&pos) const; + bool hasPosition(Position const &pos) const; // Returns the Piece*at pos. NULL if pos is out of bounds - Piece*at(const Position&pos) const; + Piece *at(Position const &pos) const; // Given screen coordinates, set the currentPiece to the proper piece // Note that this uses magic number 80 to know how large the screen is void setCurrent(int screenX, int screenY); - Piece*getCurrent(void) const; + Piece *getCurrent() const; // Set the selected piece to the parameter // At this point, toSelect is always currentPiece - void setSelected(Piece*toSelect); - Piece*getSelected(void) const; + void setSelected(Piece *toSelect); + Piece *getSelected() const; // Move a piece from one place to another // The parameters should be changed to two Positions // But such a change would require Position to handle screen values // In a network game, The two positions would be all that is needed - bool move(Piece*toMove, int screenX, int screenY); + bool move(Piece *toMove, int screenX, int screenY); }; } } diff --git a/src/board/King.cpp b/src/board/King.cpp index e3d833d..725a3d4 100644 --- a/src/board/King.cpp +++ b/src/board/King.cpp @@ -6,24 +6,24 @@ namespace chesspp { namespace board { - King::King(const Position&bPos, Color c) - :Piece(bPos, Position(80 *5,0), c, Type::KING) + King::King(Position const &bPos, Color c) + : Piece(bPos, Position(80*5, 0), c, Type::KING) { } - void King::addPosition(const Board*board, int x, int y) + void King::addPosition(Board const *board, int x, int y) { Position pos(this->boardPos.getX() + x, this->boardPos.getY() + y); if (!pos.inBounds()) return; - if (board->hasPosition(pos) &&board->at(pos)->getColor() == this->getColor()) + if (board->hasPosition(pos) && board->at(pos)->getColor() == this->getColor()) pos.setValid(false); this->trajectory.push_back(pos); } - void King::makeTrajectory(const Board*board) + void King::makeTrajectory(Board const *board) { std::clog << "KING: " << this->boardPos << " makeTrajectory" << std::endl; diff --git a/src/board/King.hpp b/src/board/King.hpp index a0771f8..938b28c 100644 --- a/src/board/King.hpp +++ b/src/board/King.hpp @@ -20,13 +20,13 @@ namespace chesspp // Maybe named a little poorly // x and y are offsets from the piece // if this position is ou-of-bounds, then nothing is added - void addPosition(const Board*board, int x, int y); + void addPosition(Board const *board, int x, int y); public: // Construct - King(const Position&bPos, Color c); + King(Position const &bPos, Color c); // Make the trajectory, see OnValidity.txt for a some info - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); }; } } diff --git a/src/board/Knight.cpp b/src/board/Knight.cpp index 91b6735..7a3756e 100644 --- a/src/board/Knight.cpp +++ b/src/board/Knight.cpp @@ -6,29 +6,29 @@ namespace chesspp { namespace board { - Knight::Knight(const Position&bPos, Color c) - :Piece(bPos, Position(80 *2,0), c, Type::KNIGHT) + Knight::Knight(Position const &bPos, Color c) + : Piece(bPos, Position(80*2, 0), c, Type::KNIGHT) { } - void Knight::makeTrajectory(const Board*board) + void Knight::makeTrajectory(Board const *board) { std::clog << "KNIGHT: " << this->boardPos << " makeTrajectory" << std::endl; this->trajectory.clear(); - addPosition(board, 1, -2 ); - addPosition(board, 2, -1 ); - addPosition(board, 2, 1 ); - addPosition(board, 1, 2 ); - addPosition(board, -1, 2 ); - addPosition(board, -2, 1 ); - addPosition(board, -2, -1 ); - addPosition(board, -1, -2 ); + addPosition(board, 1, -2); + addPosition(board, 2, -1); + addPosition(board, 2, 1); + addPosition(board, 1, 2); + addPosition(board, -1, 2); + addPosition(board, -2, 1); + addPosition(board, -2, -1); + addPosition(board, -1, -2); } - void Knight::addPosition(const Board*board, int x, int y) + void Knight::addPosition(Board const *board, int x, int y) { Position pos(this->boardPos.getX() + x, this->boardPos.getY() + y); diff --git a/src/board/Knight.hpp b/src/board/Knight.hpp index 2d7c614..e076305 100644 --- a/src/board/Knight.hpp +++ b/src/board/Knight.hpp @@ -20,13 +20,13 @@ namespace chesspp // Maybe named a little poorly // x and y are offsets from the piece // if this position is ou-of-bounds, then nothing is added - void addPosition(const Board*board, int x, int y); + void addPosition(Board const *board, int x, int y); public: - Knight(const Position&bPos, Color c); + Knight(Position const &bPos, Color c); // Make the trajectory, see OnValidity.txt for a some info - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); }; } } diff --git a/src/board/Pawn.cpp b/src/board/Pawn.cpp index 459194c..5b25cc9 100644 --- a/src/board/Pawn.cpp +++ b/src/board/Pawn.cpp @@ -6,13 +6,13 @@ namespace chesspp { namespace board { - Pawn::Pawn(const Position&bPos, Color c) - :Piece(bPos, Position(0,0), c, Type::PAWN), firstMove(true) + Pawn::Pawn(Position const &bPos, Color c) + : Piece(bPos, Position(0, 0), c, Type::PAWN), firstMove(true) { } // Other pieces can be more automatic - void Pawn::makeTrajectory(const Board*board) + void Pawn::makeTrajectory(Board const *board) { std::clog << "PAWN: " << this->boardPos << "makeTrajectory" << std::endl; @@ -24,9 +24,9 @@ namespace chesspp // Set pos to left diagonal Position pos(this->getBoardPos().getX() - 1, this->getBoardPos().getY() + offset); - if (pos.inBounds()) + if(pos.inBounds()) { - if (!board->hasPosition(pos) || board->at(pos)->getColor() == this->getColor()) + if(!board->hasPosition(pos) || board->at(pos)->getColor() == this->getColor()) pos.setValid(false); trajectory.push_back(pos); } @@ -35,19 +35,19 @@ namespace chesspp pos.setValid(true); pos.move(EAST); - if (pos.inBounds()) // Which happens, it is be a different piece otherwise + if(pos.inBounds()) // Which happens, it is be a different piece otherwise { - if (board->hasPosition(pos)) + if(board->hasPosition(pos)) pos.setValid(false); trajectory.push_back(pos); } // We keep the validity from before to check the position ahead - if (firstMove) + if(firstMove) { pos.move(0, offset); // Move Foward - if (board->hasPosition(pos)) + if(board->hasPosition(pos)) pos.setValid(false); trajectory.push_back(pos); @@ -57,9 +57,9 @@ namespace chesspp // Move to the right again, the other diagonal pos.move(EAST); pos.setValid(true); - if (pos.inBounds()) + if(pos.inBounds()) { - if (!board->hasPosition(pos) || board->at(pos)->getColor() == this->getColor()) + if(!board->hasPosition(pos) || board->at(pos)->getColor() == this->getColor()) pos.setValid(false); trajectory.push_back(pos); } @@ -70,10 +70,10 @@ namespace chesspp // en-passent will have to be thought about } - bool Pawn::move(const Position&moveTo) + bool Pawn::move(Position const &moveTo) { bool moved = Piece::move(moveTo); - if (moved) firstMove = false; + if(moved) firstMove = false; return moved; } } diff --git a/src/board/Pawn.hpp b/src/board/Pawn.hpp index 707097a..d6580e6 100644 --- a/src/board/Pawn.hpp +++ b/src/board/Pawn.hpp @@ -18,10 +18,10 @@ namespace chesspp bool firstMove; public: - Pawn(const Position&bPos, Color c); + Pawn(Position const &bPos, Color c); // Make the trajectory, see "OnValidity.txt" for more - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); // In addition to calling Piece::move(), // this function changes "firstMove" to false diff --git a/src/board/Piece.cpp b/src/board/Piece.cpp index 9e22566..c6d1fcf 100644 --- a/src/board/Piece.cpp +++ b/src/board/Piece.cpp @@ -6,22 +6,22 @@ namespace chesspp { namespace board { - Piece::Piece(const Position&bPos, const Position&tPos, Color c, Type t) - : color(c), type(t), boardPos(bPos) + Piece::Piece(Position const &bPos, Position const &tPos, Color c, Type t) + : color(c), type(t), boardPos(bPos) { int tX = tPos.getX(); - int tY = tPos.getY() + ( c == WHITE ? 0 : 80 ); + int tY = tPos.getY() + (c == WHITE ? 0 : 80); texturePos.set(tX, tY); std::clog << *this << std::endl; } - const Position&Piece::getBoardPos(void) const + const Position &Piece::getBoardPos(void) const { return boardPos; } - const Position&Piece::getTexturePos(void) const + const Position &Piece::getTexturePos(void) const { return texturePos; } @@ -30,11 +30,11 @@ namespace chesspp return color; } - const posList&Piece::getTrajectory(void) const + const posList &Piece::getTrajectory(void) const { return trajectory; } - void Piece::shootPath(const Board*board, const Direction d) + void Piece::shootPath(const Board *board, const Direction d) { Position pos = this->boardPos; @@ -64,7 +64,7 @@ namespace chesspp pos.move(d); } } - void Piece::updateTrajectory(const Board*board, const Position&oldPos, const Position&newPos) + void Piece::updateTrajectory(const Board *board, const Position &oldPos, const Position &newPos) { std::clog << ">>> Updating" << std::endl; @@ -81,7 +81,7 @@ namespace chesspp } - bool Piece::move(const Position&moveTo) + bool Piece::move(const Position &moveTo) { if (!moveTo.inBounds()) { @@ -92,7 +92,7 @@ namespace chesspp for (posList::iterator iter = trajectory.begin(); iter != trajectory.end(); iter++) { - if (*iter == moveTo &&iter->isValid()) + if (*iter == moveTo && iter->isValid()) { this->boardPos = moveTo; std::clog << "PE: moveTo success: " << moveTo << " " << boardPos << std::endl; @@ -119,7 +119,7 @@ namespace chesspp - std::ostream&operator<<(std::ostream&out, const Piece&p) + std::ostream &operator<<(std::ostream &out, const Piece &p) { return out << "PIECE: " << p.getBoardPos() << p.getTexturePos() << (p.getColor() == WHITE ? "WHITE" : "BLACK"); } diff --git a/src/board/Piece.hpp b/src/board/Piece.hpp index 046ec2c..a776902 100644 --- a/src/board/Piece.hpp +++ b/src/board/Piece.hpp @@ -40,8 +40,8 @@ namespace chesspp { private: Position texturePos; // Where in the texture is this piece? (hardcoded) - const Color color; // What color is this piece (WHITE, BLACK) - const Type type; // What type this piece is. + Color const color; // What color is this piece (WHITE, BLACK) + Type const type; // What type this piece is. protected: @@ -50,17 +50,15 @@ namespace chesspp public: - Piece(const Position&bPos, const Position&tPos, Color c, Type t); - virtual ~Piece() - { - } + Piece(Position const &bPos, Position const &tPos, Color c, Type t); + virtual ~Piece() = default; // Standard Accesors - const Position&getBoardPos(void) const; - const Position&getTexturePos(void) const; - Color getColor(void) const; - Type getType(void) const; - const posList&getTrajectory(void) const; + const Position&getBoardPos() const; + const Position&getTexturePos() const; + Color getColor() const; + Type getType() const; + const posList&getTrajectory() const; // We need to know these things :) // If a piece moves, it's trajectory needs to be checked for a king @@ -68,33 +66,32 @@ namespace chesspp // A pawn thinks the position ahead of it is valid // Kings don't like to move into an enemy's valid position // The converse for the pawn's diagonal - virtual bool isPawn(void); - virtual bool isKing(void); + virtual bool isPawn(); + virtual bool isKing(); // Make pure virtual when all pieces have the function - virtual void makeTrajectory(const Board*board) + virtual void makeTrajectory(Board const *board) { } // Used by Queen, Bishop, and Rook // This function moves in Direction d until the end of the board // These Positions are added to the piece's trajectory - void shootPath(const Board*board, const Direction d); + void shootPath(Board const *board, Direction const d); // This function is called for every piece after a piece moves // If the two Positions are in the piece's trajectory // Then makeTrajectory is called (makeTrajectory starts from scratch) // Maybe there is a better way to do it ? // Knights would be easy, would have to do virtual - void updateTrajectory(const Board*board, const Position&old, const Position&knew); + void updateTrajectory(Board const *board, Position const &old, Position const &knew); // Moves the piece. Most pieces use this/ // As of now, only Pawns do not because pawns have a "firstMove" // Kings would also need to override this - virtual bool move(const Position&moveTo); + virtual bool move(Position const &moveTo); - // Why not? :) - friend std::ostream&operator<<(std::ostream&out, const Piece&p); + friend std::ostream &operator<<(std::ostream &out, Piece const &p); }; } } diff --git a/src/board/Position.cpp b/src/board/Position.cpp index e9abf32..be7e29d 100644 --- a/src/board/Position.cpp +++ b/src/board/Position.cpp @@ -4,35 +4,26 @@ namespace chesspp { namespace board { - Position::Position(void) - :x(-1), y(-1), valid(true) - { - - } - Position::Position(const Position&other) - :x(other.x), y(other.y), valid(other.valid) - { - - } Position::Position(int x, int y) - :x(x), y(y), valid(true) + : x(x) + , y(y) + , valid(true) { - } - bool Position::inBounds(void) const + bool Position::inBounds() const { return x >= 0 &&x < WIDTH &&y >= 0 &&y < WIDTH; } - bool Position::isValid(void) const + bool Position::isValid() const { return valid; } - int Position::getX(void) const + int Position::getX() const { return x; } - int Position::getY(void) const + int Position::getY() const { return y; } @@ -66,18 +57,13 @@ namespace chesspp valid = v; } - bool Position::operator==(const Position&other) const + bool Position::operator==(Position const &other) const { return this->x == other.x &&this->y == other.y; } - bool Position::operator!=(const Position&other) const - { - // return !operator==(other); // ? - return this->x != other.x || this->y != other.y; - } - std::ostream&operator<<(std::ostream&out, const Position&pos) + std::ostream &operator<<(std::ostream &out, Position const &pos) { return out << "( " << pos.getX() << ", " << pos.getY() << ", " << ( pos.isValid()? 'V' : 'x' ) << ")"; } diff --git a/src/board/Position.hpp b/src/board/Position.hpp index 4b4d696..28640d7 100644 --- a/src/board/Position.hpp +++ b/src/board/Position.hpp @@ -38,15 +38,14 @@ namespace chesspp bool valid; public: - Position(void); - Position(const Position&other); - Position(int x, int y); + Position(int x = -1, int y = -1); + Position(Position const &other) = default; // Standard accessors - bool inBounds(void) const; - bool isValid(void) const; - int getX(void) const; - int getY(void) const; + bool inBounds() const; + bool isValid() const; + int getX() const; + int getY() const; // Moves position relative to itself void move(int x, int y); @@ -57,11 +56,9 @@ namespace chesspp // Changes the validity void setValid(bool v); - bool operator==(const Position&other) const; - bool operator!=(const Position&other) const; // Not Used - - friend std::ostream&operator<<(std::ostream&out, const Position&pos); + bool operator==(Position const &other) const; + friend std::ostream&operator<<(std::ostream &out, Position const &pos); }; } } diff --git a/src/board/Queen.cpp b/src/board/Queen.cpp index adaf4bf..589ec22 100644 --- a/src/board/Queen.cpp +++ b/src/board/Queen.cpp @@ -6,13 +6,13 @@ namespace chesspp { namespace board { - Queen::Queen(const Position&bPos, Color c) - :Piece(bPos, Position(80 *4,0), c, Type::QUEEN) + Queen::Queen(Position const &bPos, Color c) + :Piece(bPos, Position(80*4,0), c, Type::QUEEN) { } - void Queen::makeTrajectory(const Board*board) + void Queen::makeTrajectory(const Board *board) { std::clog << "QUEEN: " << this->boardPos << " makeTrajectory" << std::endl; diff --git a/src/board/Queen.hpp b/src/board/Queen.hpp index c64af9d..9172269 100644 --- a/src/board/Queen.hpp +++ b/src/board/Queen.hpp @@ -14,11 +14,10 @@ namespace chesspp { class Queen : public Piece { - private: public: - Queen(const Position&bPos, Color c); + Queen(Position const &bPos, Color c); - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); }; } diff --git a/src/board/Rook.cpp b/src/board/Rook.cpp index 0932301..4a49966 100644 --- a/src/board/Rook.cpp +++ b/src/board/Rook.cpp @@ -6,12 +6,12 @@ namespace chesspp { namespace board { - Rook::Rook(const Position&bPos, Color c) - :Piece(bPos, Position(80 *1,0), c, Type::ROOK) + Rook::Rook(Position const &bPos, Color c) + : Piece(bPos, Position(80*1, 0), c, Type::ROOK) { } - void Rook::makeTrajectory(const Board*board) + void Rook::makeTrajectory(Board const *board) { std::clog << "ROOK: " << this->boardPos << " makeTrajectory" << std::endl; diff --git a/src/board/Rook.hpp b/src/board/Rook.hpp index cdd72a7..cbdafe5 100644 --- a/src/board/Rook.hpp +++ b/src/board/Rook.hpp @@ -14,11 +14,10 @@ namespace chesspp { class Rook : public Piece { - private: public: - Rook(const Position&bPos, Color c); + Rook(Position const &bPos, Color c); - virtual void makeTrajectory(const Board*board); + virtual void makeTrajectory(Board const *board); }; } } diff --git a/src/config/Configuration.hpp b/src/config/Configuration.hpp index e9d659a..f3f3c2f 100644 --- a/src/config/Configuration.hpp +++ b/src/config/Configuration.hpp @@ -86,18 +86,18 @@ namespace chesspp BoardConfig() : Configuration("config.json") , initial_layout (res_path + std::string(reader()["chesspp"]["board"]["initial_layout"])) - , board_width(reader()["chesspp"]["board"]["width"]) - , board_height(reader()["chesspp"]["board"]["height"]) - , cell_width(reader()["chesspp"]["board"]["cell_width"]) - , cell_height(reader()["chesspp"]["board"]["cell_height"]) + , board_width (reader()["chesspp"]["board"]["width"] ) + , board_height (reader()["chesspp"]["board"]["height"] ) + , cell_width (reader()["chesspp"]["board"]["cell_width"] ) + , cell_height (reader()["chesspp"]["board"]["cell_height"] ) { } - std::string getInitialLayout() { return initial_layout; } - uint8_t getBoardWidth() { return board_width; } - uint8_t getBoardHeight() { return board_height; } - uint16_t getCellWidth() { return cell_width; } - uint16_t getCellHeight() { return cell_height; } + std::string getInitialLayout() const noexcept { return initial_layout; } + uint8_t getBoardWidth () const noexcept { return board_width; } + uint8_t getBoardHeight () const noexcept { return board_height; } + uint16_t getCellWidth () const noexcept { return cell_width; } + uint16_t getCellHeight () const noexcept { return cell_height; } }; class GraphicsConfig : public Configuration @@ -107,15 +107,15 @@ namespace chesspp public: GraphicsConfig() : Configuration("config.json") - , path_board(res_path + std::string(reader()["chesspp"]["board"]["images"]["board"])) - , path_pieces(res_path + std::string(reader()["chesspp"]["board"]["images"]["pieces"])) + , path_board (res_path + std::string(reader()["chesspp"]["board"]["images"]["board"]) ) + , path_pieces (res_path + std::string(reader()["chesspp"]["board"]["images"]["pieces"]) ) , path_validMove(res_path + std::string(reader()["chesspp"]["board"]["images"]["validMove"])) { } - std::string getSpritePath_board() { return path_board; } - std::string getSpritePath_pieces() { return path_pieces; } - std::string getSpritePath_validMove() { return path_validMove; } + std::string getSpritePath_board (){ return path_board; } + std::string getSpritePath_pieces (){ return path_pieces; } + std::string getSpritePath_validMove(){ return path_validMove; } }; } } diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index 25082c3..c132b26 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -1,10 +1,13 @@ #include "Graphics.hpp" +#include + namespace chesspp { namespace graphics { - GraphicsHandler::GraphicsHandler( sf::RenderWindow *_display ) : display(_display) + GraphicsHandler::GraphicsHandler(sf::RenderWindow *display) + : display(display) { try { @@ -19,15 +22,13 @@ namespace chesspp } catch(Exception &e) { -#ifdef _DEBUG - cout << "Error: " << e.what() << endl; -#endif + std::cerr << "Error: " << e.what() << std::endl; } } void GraphicsHandler::drawSpriteAtCell(sf::Sprite &s, const int x, const int y) { - s.setPosition(x *cell_size, y *cell_size); + s.setPosition(x*cell_size, y*cell_size); display->draw(s); } void GraphicsHandler::drawBackground() @@ -62,25 +63,33 @@ namespace chesspp for (auto &i: pSelect->getTrajectory()) { if(i.isValid()) + { drawValidMove(i.getX(), i.getY()); + } } else if (pCurrent) for (auto &i: pCurrent->getTrajectory()) { if(i.isValid()) + { drawValidMove(i.getX(), i.getY()); + } } // Draw the non-selected pieces for(auto &i: b->pieces) { if(i &&i != b->getSelected()) + { drawPiece(i); + } } // Draw the selected piece - if (b->getSelected()) + if(b->getSelected()) + { drawPieceAt(b->getSelected(), sf::Mouse::getPosition(*display)); + } } } } diff --git a/src/graphics/Graphics.hpp b/src/graphics/Graphics.hpp index 4a12cdb..ccb48f1 100644 --- a/src/graphics/Graphics.hpp +++ b/src/graphics/Graphics.hpp @@ -17,7 +17,7 @@ namespace chesspp sf::RenderWindow *display; public: - GraphicsHandler(sf::RenderWindow *_display); + GraphicsHandler(sf::RenderWindow *display); //Draws any sprite in the center of cell at (x, y). Assumes sprite is 80x80 as well. void drawSpriteAtCell(sf::Sprite &s, const int x, const int y);