Raylib Bubbles
C++11 Raylib bubble shooter game.
|
Handles the game window and provides rendering functionality. More...
#include <window.hpp>
Public Member Functions | |
GameWindow () | |
Initializes the game window with specific configurations. More... | |
~GameWindow () | |
Cleans up game window resources. More... | |
Getters for window properties. | |
float | getWidth () const |
float | getHeight () const |
size_t | getFPS () const |
Inline calls to Raylib main loop functions. | |
bool | shouldClose () const |
void | beginDrawing () |
void | endDrawing () |
Public drawing methods. | |
void | drawText (const std::string &text, const float x, const float y, const float scale=1.0f, const Color &color=WHITE) |
Draws text at a specific position. More... | |
void | drawBubble (const float x, const float y, const float radius, const size_t hue) |
Draws a bubble at a specific position. More... | |
void | drawBoard (const PlacedBoard &boardData) |
Draws the provided placed game board. More... | |
void | drawHUD (const GameHUD &hud) |
Public background methods. | |
void | stepBackground () |
Steps the background movement animation. More... | |
void | loadBackground (const size_t index) |
Loads a background image into the game window. More... | |
void | applyLoadedBackground () |
Applies the loaded background to the game window. More... | |
Public methods for game timing. | |
double | time () const |
float | getFrameDeltaRatio () const |
Gets the ratio between the time the previous frame has taken and 60 FPS. More... | |
Getters for counts of loaded resources. | |
size_t | countBubbleTextures () const |
Gets the number of bubble textures loaded. More... | |
size_t | countBackgroundImages () const |
Gets the number of background images loaded. More... | |
Raylib input handling. | |
enum class | HandledKeys { ACTION = KEY_LEFT_SHIFT , LEFT = KEY_Z , RIGHT = KEY_X } |
bool | inputOnce (const HandledKeys key) const |
bool | inputHold (const HandledKeys key) const |
Handles the game window and provides rendering functionality.
This class includes most rendering functionality for primary components of the game.
feature/implement_game
. GameWindow::GameWindow | ( | ) |
Initializes the game window with specific configurations.
This constructor initializes the game window using configurations specified in the game's configuration file. It sets up the window dimensions, frame rate, and board size based on these configurations. The initialization process involves setting up the Raylib window, loading necessary fonts, images, and textures for the game.
GameWindow::~GameWindow | ( | ) |
Cleans up game window resources.
This destructor cleans up the resources used by the game window, including the window itself, fonts, images, and textures.
void GameWindow::applyLoadedBackground | ( | ) |
Applies the loaded background to the game window.
This method swaps the current and new Texture2D loaded background textures, allowing a buffered background load. Since loading the image into VRAM and unloading the old one is handled by loadBackground(), all this method does is swap the bgTexSelect
boolean index to pick the correct background texture, as well as configure the correct viewport size for the LissajousView being used.
|
inline |
Gets the number of background images loaded.
|
inline |
Gets the number of bubble textures loaded.
void GameWindow::drawBoard | ( | const PlacedBoard & | boardData | ) |
Draws the provided placed game board.
This method draws iterates through the board's cells and draws bubbles at the appropriate positions, based on the board scale and position. check out PlacedBoard for more information.
cols
and cols - 1
or not. The GameBoard::getColAlign() method is used to determine this.void GameWindow::drawBubble | ( | const float | x, |
const float | y, | ||
const float | radius, | ||
const size_t | hue | ||
) |
Draws a bubble at a specific position.
x | The x coordinate to draw the bubble. |
y | The y coordinate to draw the bubble. |
radius | The radius of the bubble. |
hue | The hue property of the bubble |
This method draws a bubble texture at the requested position on the game window. Check out GameBoard::BubbleCell for more information on the hue property.
std::out_of_range | if the hue is not a valid index in the bubble textures. |
void GameWindow::drawText | ( | const std::string & | text, |
const float | x, | ||
const float | y, | ||
const float | scale = 1.0f , |
||
const Color & | color = WHITE |
||
) |
Draws text at a specific position.
text | The text to draw. |
x | The x coordinate to draw the text. |
y | The y coordinate to draw the text. |
scale | The scale of the text (default 1.0f). |
color | The color of the text (default WHITE). |
This method draws text using the main font loaded on construction at a specific position on the game window. The text can be scaled and colored as needed.
|
inline |
Gets the ratio between the time the previous frame has taken and 60 FPS.
void GameWindow::loadBackground | ( | const size_t | index | ) |
Loads a background image into the game window.
index | The index of the background image to load. |
This method loads a background image that has been specified in the game's configuration file. The index corresponds to the order in which the images are listed in the configuration file. The picked image is loaded into a Texture2D (VRAM) and is ready to be swapped with the current background once applyLoadedBackground() is called (this way double buffering is achieved).
std::out_of_range | if the index is not a valid index in the background images. |
void GameWindow::stepBackground | ( | ) |
Steps the background movement animation.