diff --git a/breakout/breakout.cpp b/breakout/breakout.cpp index 2ace101..3b55456 100644 --- a/breakout/breakout.cpp +++ b/breakout/breakout.cpp @@ -9,6 +9,7 @@ #include "../dependencies/include/glad/glad.h" #include "./game.hpp" #include "./resourceManager.hpp" +#include "./constants.hpp" // GLFW function declarations void framebuffer_size_callback(GLFWwindow *window, int width, int height); @@ -150,7 +151,7 @@ void key_callback_sad(int key) { void key_callback(GLFWwindow *window, int key, int /*scancode*/, int action, int /*mode*/) { // Define the array type for keys - const int MAX_KEYS_TRACKED = 1024; + const int MAX_KEYS_TRACKED = constants::MAX_KEYS_TRACKED; using KeyArray = std::array; exit_window(window, key, action); if (key >= 0 && key < MAX_KEYS_TRACKED) { diff --git a/breakout/constants.hpp b/breakout/constants.hpp new file mode 100644 index 0000000..d7c5de0 --- /dev/null +++ b/breakout/constants.hpp @@ -0,0 +1,10 @@ +// Copyright [2023] Krzysztof Rudnicki +#ifndef BREAKOUT_CONSTANTS_HPP_ +#define BREAKOUT_CONSTANTS_HPP_ + +namespace constants { + constexpr int MAX_KEYS_TRACKED { 1024 }; + constexpr int GAME_WINDOW_SIZE_ALLIGNMENT { 8 }; +} + +#endif // BREAKOUT_CONSTANTS_HPP_ diff --git a/breakout/game.cpp b/breakout/game.cpp index 25154e6..dc6db34 100644 --- a/breakout/game.cpp +++ b/breakout/game.cpp @@ -3,14 +3,17 @@ #define HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_GAME_CPP #include "../breakout/game.hpp" -Game::Game(unsigned int width, unsigned int height) - : State(GAME_ACTIVE), Keys(), Width(width), Height(height) {} + + +Game::Game(GameWindowSize size) + : State(GAME_ACTIVE), Keys(), Width(size.width), Height(size.height) { +} void Game::Init() {} -void Game::Update(double dt) {} +void Game::Update(double deltaTime) {} -void Game::ProcessInput(double dt) {} +void Game::ProcessInput(double deltaTime) {} void Game::Render() {} diff --git a/breakout/game.hpp b/breakout/game.hpp index 8be52b0..5fcc3f4 100644 --- a/breakout/game.hpp +++ b/breakout/game.hpp @@ -1,30 +1,44 @@ // Copyright [2023] Krzysztof Rudnicki -#ifndef HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_GAME_HPP -#define HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_GAME_HPP -#include +#ifndef BREAKOUT_GAME_HPP_ +#define BREAKOUT_GAME_HPP_ #include +#include + #include "../dependencies/include/glad/glad.h" +#include "./constants.hpp" + +struct GameWindowSize { + unsigned int width; + unsigned int height; +} __attribute__((aligned(constants::GAME_WINDOW_SIZE_ALLIGNMENT))); // Represents the current state of the game enum GameState { GAME_ACTIVE, GAME_MENU, GAME_WIN }; class Game { -public: + private: // game state GameState State; - std::array Keys; + std::array Keys; unsigned int Width, Height; + public: // constructor/destructor - Game(unsigned int width, unsigned int height); + explicit Game(GameWindowSize size); ~Game() = default; + + // rule of five + Game(const Game& other) = delete; + Game& operator=(const Game& other) = delete; + Game(Game&& other) noexcept = delete; + Game& operator=(Game&& other) noexcept = delete; // initialize game state (load all shaders/textures/levels) void Init(); // game loop - void ProcessInput(double dt); - void Update(double dt); + void ProcessInput(double deltaTime); + void Update(double deltaTime); void Render(); }; -#endif // HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_GAME_HPP +#endif // BREAKOUT_GAME_HPP_