tavli
diff src/board.h @ 17:16a420432aa3
pieces on the board
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 28 Jun 2015 23:04:37 +0300 |
parents | f1ecc2439802 |
children | c3fbf9616dbd |
line diff
1.1 --- a/src/board.h Sun Jun 28 08:48:25 2015 +0300 1.2 +++ b/src/board.h Sun Jun 28 23:04:37 2015 +0300 1.3 @@ -5,16 +5,33 @@ 1.4 #include "object.h" 1.5 #include "image.h" 1.6 1.7 -#define NUM_SLOTS 24 1.8 -#define MAX_PUCKS 30 1.9 +#define NUM_SLOTS 20 1.10 +#define PLAYER_PIECES 15 1.11 +#define MAX_PIECES (PLAYER_PIECES * 2) 1.12 1.13 -enum { EMPTY = 0, MINE, OTHER }; 1.14 +enum { MINE, OTHER }; 1.15 + 1.16 +class Piece { 1.17 +private: 1.18 + int prev_slot, prev_level; 1.19 + unsigned long move_start; 1.20 + 1.21 +public: 1.22 + int owner, slot, level; 1.23 + 1.24 + Piece(); 1.25 + 1.26 + void move_to(int slot, int level, bool anim = true); 1.27 +}; 1.28 + 1.29 1.30 class Board { 1.31 private: 1.32 - int slots[NUM_SLOTS][MAX_PUCKS]; 1.33 + Piece pieces[MAX_PIECES]; 1.34 + int hist[NUM_SLOTS + 1]; 1.35 + 1.36 std::vector<Object*> obj; 1.37 - Object *puck_obj; 1.38 + Object *piece_obj; 1.39 1.40 Image img_wood, img_field, img_hinge; 1.41 1.42 @@ -29,6 +46,12 @@ 1.43 void destroy(); 1.44 1.45 void clear(); 1.46 + void setup(); 1.47 + 1.48 + int slot_pieces(int slot) const; 1.49 + bool move_piece(int id, int slot, bool anim = true); 1.50 + 1.51 + Vector3 piece_pos(int slot, int level = 0) const; 1.52 1.53 void draw() const; 1.54 };