summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Enders <smenders@gmail.com>2021-01-21 22:18:07 -0500
committerStephen Enders <smenders@gmail.com>2021-01-21 22:18:07 -0500
commita28b7208180937f21cf9cfa8542d0490cd643daa (patch)
treece80adb2d59c83dc0703711ab6a7567ce4c6a1de
parent47b8018228f8d461a1487182ad176bfd41e55e9c (diff)
Rearrange sprites
-rw-r--r--helper.cpp17
-rw-r--r--helper.hpp16
-rw-r--r--res/ur.asepritebin1547 -> 1647 bytes
-rw-r--r--res/ur.pngbin1769 -> 1947 bytes
4 files changed, 18 insertions, 15 deletions
diff --git a/helper.cpp b/helper.cpp
index 04c95cf..0391d86 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -29,10 +29,10 @@ loadTextures(const char* path)
// increment through the textures
inline int
-next(int* p)
+next(int* p, int max)
{
int i = *p;
- (*p) = (i + 1) % 2;
+ (*p) = (i + 1) % max;
return i;
}
@@ -41,7 +41,7 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
{
auto sprites = std::make_shared<std::vector<sf::Sprite>>();
sf::Texture& star_texture = (*textures)[STAR_TILE];
- sf::Texture& blank_texture = (*textures)[BLANK_TILE];
+ int blank_idx = 0;
int sp_idx = 0;
// p1 pieces
// p1 star
@@ -53,7 +53,7 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
}
// p1 start
for (int i = 0; i < 3; i++) {
- sf::Texture& t = (*textures)[P1_BOARD_TILES[next(&sp_idx)]];
+ sf::Texture& t = (*textures)[P1_BOARD_TILES[next(&sp_idx, 2)]];
sf::Sprite s;
s.setTexture(t);
s.setPosition(pos(4 + i, 5));
@@ -66,7 +66,7 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
end_star.setPosition(pos(9, 5));
sprites->push_back(end_star);
- sf::Texture& t = (*textures)[P1_BOARD_TILES[next(&sp_idx)]];
+ sf::Texture& t = (*textures)[P1_BOARD_TILES[next(&sp_idx, 2)]];
sf::Sprite s;
s.setTexture(t);
s.setPosition(pos(10, 5));
@@ -78,7 +78,8 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
if (i == 3) {
s.setTexture(star_texture);
} else {
- s.setTexture(blank_texture);
+ sf::Texture& t = (*textures)[BLANK_TILES[next(&blank_idx, 3)]];
+ s.setTexture(t);
}
s.setPosition(pos(3 + i, 4));
sprites->push_back(s);
@@ -93,7 +94,7 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
}
// p2 start
for (int i = 0; i < 3; i++) {
- sf::Texture& t = (*textures)[P2_BOARD_TILES[next(&sp_idx)]];
+ sf::Texture& t = (*textures)[P2_BOARD_TILES[next(&sp_idx, 2)]];
sf::Sprite s;
s.setTexture(t);
s.setPosition(pos(4 + i, 3));
@@ -106,7 +107,7 @@ createBoard(std::shared_ptr<std::vector<sf::Texture>> textures)
end_star.setPosition(pos(9, 3));
sprites->push_back(end_star);
- sf::Texture& t = (*textures)[P2_BOARD_TILES[next(&sp_idx)]];
+ sf::Texture& t = (*textures)[P2_BOARD_TILES[next(&sp_idx, 2)]];
sf::Sprite s;
s.setTexture(t);
s.setPosition(pos(10, 3));
diff --git a/helper.hpp b/helper.hpp
index d0e86ce..3e7ffbb 100644
--- a/helper.hpp
+++ b/helper.hpp
@@ -16,16 +16,18 @@ 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 P2_PIECE = 5;
+static const int P1_PIECE = 19;
+static const int P2_PIECE = 18;
static const int P1_BOARD_TILES[2] = { 0, 1 };
static const int P2_BOARD_TILES[2] = { 2, 3 };
static const int STAR_TILE = 4;
-static const int BLANK_TILE = 9;
-static const int DIE_0 = 8;
-static const int DIE_1 = 7;
-static const int NUMS_TILES[8] = { 10, 11, 12, 13, 14, 15, 16, 17 };
-static const int ROLL_TILES[2] = { 18, 19 };
+static const int BLANK_TILES[3] = { 5, 6, 7 };
+static const int P1_END = 22;
+static const int P2_END = 23;
+static const int DIE_0 = 17;
+static const int DIE_1 = 16;
+static const int NUMS_TILES[8] = { 8, 9, 10, 11, 12, 13, 14, 15 };
+static const int ROLL_TILES[2] = { 20, 21 };
static const char* TITLE = "Royal Game of Ur";
static const sf::Color GLOBAL_MASK(255, 0, 255, 255);
diff --git a/res/ur.aseprite b/res/ur.aseprite
index a7a25eb..9e431ec 100644
--- a/res/ur.aseprite
+++ b/res/ur.aseprite
Binary files differ
diff --git a/res/ur.png b/res/ur.png
index ff20a18..49800c7 100644
--- a/res/ur.png
+++ b/res/ur.png
Binary files differ