summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Enders <smenders@gmail.com>2021-01-18 16:29:23 -0500
committerStephen Enders <smenders@gmail.com>2021-01-18 16:33:07 -0500
commit1f8159534f30d3e46f53cebb788c91153103edcb (patch)
tree4ad7f06a9ac148946be319d724be3e38ab6e7e3b
parent367292e545f5a15e9dc68d60e5f4fe6835eecce1 (diff)
Move helper.h to helper.hpp and reformat
-rw-r--r--CMakeLists.txt2
-rw-r--r--helper.cpp2
-rw-r--r--helper.hpp (renamed from helper.h)34
-rw-r--r--ur.cpp2
4 files changed, 18 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index be11c85..f7a56e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ set(EXECUTABLE_NAME ur)
set(SFML_LIBRARIES sfml-system sfml-window sfml-graphics)
find_package(SFML 2.5 REQUIRED COMPONENTS system window graphics)
-add_executable(${EXECUTABLE_NAME} ur.cpp helper.h helper.cpp)
+add_executable(${EXECUTABLE_NAME} ur.cpp helper.hpp helper.cpp)
target_link_libraries(${EXECUTABLE_NAME} ${SFML_LIBRARIES})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/helper.cpp b/helper.cpp
index f1bb417..04c95cf 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -1,4 +1,4 @@
-#include "helper.h"
+#include "helper.hpp"
#include <iostream>
std::shared_ptr<std::vector<sf::Texture>>
diff --git a/helper.h b/helper.hpp
index 74c11ca..d0e86ce 100644
--- a/helper.h
+++ b/helper.hpp
@@ -9,14 +9,14 @@
static const unsigned int SPRITE_SIZE = 16;
static const unsigned int NUM_PIECES = 7;
-static const unsigned int SAFE_SPACE = 7; // 0-indexed
+static const unsigned int SAFE_SPACE = 7; // 0-indexed
static const unsigned int EXIT_SPACE = 14; // final space + 1
static const float ZOOM = 0.5f;
static const float SPRITE_ROWS = 9.f;
static const float SPRITE_COLS = 14.f;
static const float SCR_W = SPRITE_SIZE / ZOOM * SPRITE_COLS / ZOOM;
static const float SCR_H = SPRITE_SIZE / ZOOM * SPRITE_ROWS / ZOOM;
-static const int P1_PIECE = 6;
+static const int P1_PIECE = 6;
static const int P2_PIECE = 5;
static const int P1_BOARD_TILES[2] = { 0, 1 };
static const int P2_BOARD_TILES[2] = { 2, 3 };
@@ -45,7 +45,6 @@ struct piece_t
sf::Sprite sprite;
};
-
struct player_t
{
int score;
@@ -59,14 +58,14 @@ struct dice_t
sf::Sprite sprite;
};
-
std::shared_ptr<std::vector<sf::Texture>>
loadTextures(const char* path);
std::shared_ptr<std::vector<sf::Sprite>>
createBoard(std::shared_ptr<std::vector<sf::Texture>> textures);
-sf::Font loadFont();
+sf::Font
+loadFont();
std::shared_ptr<struct player_t>
createPlayer(sf::Texture& pieceTexture);
@@ -80,27 +79,24 @@ createAllDice(sf::Texture& die0Texture, sf::Texture& die1Texture);
std::shared_ptr<std::vector<sf::Sprite>>
createRollSprites(sf::Texture& t1, sf::Texture& t2);
-void makeNum(
- sf::Sprite* sprite_ptr,
- int num,
- std::shared_ptr<std::vector<sf::Texture>> textures);
+void
+makeNum(sf::Sprite* sprite_ptr,
+ int num,
+ std::shared_ptr<std::vector<sf::Texture>> textures);
bool
clickedPiece(sf::Vector2i mousePosition, std::shared_ptr<struct piece_t> piece);
bool
-canMovePiece(
- std::shared_ptr<struct piece_t> piece,
- int roll,
- std::shared_ptr<std::vector<struct piece_t>> myPieces,
- std::shared_ptr<std::vector<struct piece_t>> enemyPieces);
+canMovePiece(std::shared_ptr<struct piece_t> piece,
+ int roll,
+ std::shared_ptr<std::vector<struct piece_t>> myPieces,
+ std::shared_ptr<std::vector<struct piece_t>> enemyPieces);
-std::vector<int>
-getLegalMoves(
- std::shared_ptr<struct player_t> activePlayer,
- std::shared_ptr<struct player_t> opponent);
+std::vector<int>
+getLegalMoves(std::shared_ptr<struct player_t> activePlayer,
+ std::shared_ptr<struct player_t> opponent);
sf::Vector2f
pos(float c, float r);
#endif
-
diff --git a/ur.cpp b/ur.cpp
index d1f87ed..eb68ad7 100644
--- a/ur.cpp
+++ b/ur.cpp
@@ -1,4 +1,4 @@
-#include "helper.h"
+#include "helper.hpp"
#include <SFML/Graphics.hpp>
#include <iostream>
#include <string>