tavli

view src/board.h @ 24:0aadb519b5ee

correct highlighting
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 08 Jul 2015 15:11:58 +0300
parents c3fbf9616dbd
children
line source
1 #ifndef BOARD_H_
2 #define BOARD_H_
4 #include <vector>
5 #include "object.h"
6 #include "mesh.h"
7 #include "image.h"
9 #define NUM_SLOTS 20
10 #define PLAYER_PIECES 15
11 #define MAX_PIECES (PLAYER_PIECES * 2)
13 enum { MINE, OTHER };
15 class Piece {
16 private:
17 int prev_slot, prev_level;
18 unsigned long move_start;
20 public:
21 int owner, slot, level;
23 Piece();
25 void move_to(int slot, int level, bool anim = true);
26 };
28 // for slot bounds
29 class Quad {
30 public:
31 Triangle tri0, tri1;
33 Quad();
34 Quad(const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
36 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
37 };
39 class Board {
40 private:
41 Piece pieces[MAX_PIECES];
42 int hist[NUM_SLOTS + 1];
43 Quad slotbb[NUM_SLOTS];
44 int slot_sel; // current slot selection
46 std::vector<Object*> obj;
47 Object *piece_obj;
49 Image img_wood, img_field, img_hinge, img_highlight;
51 bool generate();
52 bool generate_textures();
54 public:
55 Board();
56 ~Board();
58 bool init();
59 void destroy();
61 void clear();
62 void setup();
64 int slot_pieces(int slot) const;
65 bool move_piece(int id, int slot, bool anim = true);
67 Vector3 piece_pos(int slot, int level = 0) const;
69 int slot_hit(const Ray &ray) const;
70 void select_slot(int idx);
71 int get_selected_slot() const;
73 void draw() const;
74 };
76 #endif // BOARD_H_