summaryrefslogtreecommitdiff
path: root/helper.h
blob: dbebfb68f73eedbf28d0e604d0dbca43f0f541a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef UR_HELPER_H
#define UR_HELPER_H

#include <SFML/Graphics.hpp>
#include <memory>
#include <vector>

// BOARD LAYOUT [0, 1, 2, 3](start) [4,5,6,7,8,9,10,11](middle), [12,13](end)

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 EXIT_SPACE = 14; // final space + 1

static const sf::Color GLOBAL_MASK(255, 0, 255, 255);

struct piece_t
{
  int id;
  int position;
  std::shared_ptr<sf::Sprite> sprite;
};


struct player_t
{
  int score;
  std::shared_ptr<std::vector<std::shared_ptr<struct piece_t>>> pieces;
};


std::shared_ptr<std::vector<sf::Texture>>
loadTextures(const char* path);

sf::Font loadFont();

std::shared_ptr<struct player_t>
createPlayer(sf::Texture pieceTexture);

std::shared_ptr<struct piece_t>
createPiece(int id, sf::Texture texture);

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<std::shared_ptr<struct piece_t>>> myPieces,
    std::shared_ptr<std::vector<std::shared_ptr<struct piece_t>>> enemyPieces);

std::vector<int> getLegalMoves(std::shared_ptr<struct player_t> activePlayer, std::shared_ptr<struct player_t> opponent);
#endif