Raylib Bubbles
C++11 Raylib bubble shooter game.
hud.hpp
1 #ifndef HUD_HPP_
2 #define HUD_HPP_
3 
4 #include <array>
5 #include <string>
6 #include <sstream>
7 #include <cmath>
8 
9 #include <raylib.h>
10 
11 #include "pboard.hpp"
12 #include "util.hpp"
13 
29 class GameHUD {
30 public:
31 
47  struct ArrowPiece {
48  Texture2D tex;
49  float x;
50  float y;
51  float w;
52  float h;
53  float angle;
54  };
55 
69  struct Arrow {
70  std::array<ArrowPiece, 3> pieces;
71  float direction;
72  float scale;
73  };
74 
75  struct HeldBubble {
76  float x;
77  float y;
78  float radius;
79  size_t hue;
80  };
81 
82  GameHUD(const PlacedBoard::BoardDims& boardDims);
83 
84  ~GameHUD();
85 
88 
93  void updateArrowDirection(const float offsetRad);
94 
100  void updateHUDPosition(const float offsetX, const float offsetY);
101 
106  inline const GameHUD::Arrow& getArrow() const {
107  return arrow;
108  }
109 
114  inline float getArrowWidth() const {
115  return arrow.pieces[0].w;
116  }
117 
122  inline float getArrowHeight() const {
123  return arrow.pieces[0].h + arrow.pieces[1].h + arrow.pieces[2].h;
124  }
125 
127 
130 
131  inline const size_t getHeld() const {
132  return held[0].hue;
133  }
134 
135  inline const std::array<HeldBubble, 5>& getHeldBubbles() const {
136  return held;
137  }
138 
139  void setHeldBubble(const size_t index, const size_t hue);
140 
141  void shiftInHeldBubbles(const size_t hue);
142 
143  inline size_t heldSize() const {
144  return held.size();
145  }
146 
148 
149 private:
150  const PlacedBoard::BoardDims& boardDims;
151 
152  Arrow arrow;
153  std::array<HeldBubble, 5> held;
154 
155  void loadArrow();
156  void loadHeldBubbles();
157 };
158 
159 #endif
Provides an object to manage the game HUD state.
Definition: hud.hpp:29
float getArrowWidth() const
Calculates the expected width with the current arrow layout.
Definition: hud.hpp:114
void updateHUDPosition(const float offsetX, const float offsetY)
Updates the position of the HUD.
Definition: hud.cpp:36
void updateArrowDirection(const float offsetRad)
Updates the direction of the arrow.
Definition: hud.cpp:19
float getArrowHeight() const
Calculates the expected height with the current arrow layout.
Definition: hud.hpp:122
const GameHUD::Arrow & getArrow() const
Gives readonly access to the arrow data.
Definition: hud.hpp:106
Represents a texture of the bubble shooter the player controls.
Definition: hud.hpp:47
The data structure used to handle the player's arrow.
Definition: hud.hpp:69
Definition: hud.hpp:75
Describes the offset and scale of the board in reference to the window.
Definition: pboard.hpp:26