Loading CMakeLists.txt +1 −1 Changes for CMakeLists.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -18,5 +18,5 @@ include_directories("glitter/ext/tinyobjloader" ${OPENGL_INCLUDE_DIR}) add_executable(GLE-test src/main.cpp src/RenderObject.cpp src/GuiElement.cpp src/RenderObjectPart.cpp src/GlApplication.cpp src/model/Spaceship.cpp src/model/Asteroid.cpp src/model/Entity.cpp src/model/Missile.cpp) src/model/Spaceship.cpp src/model/Asteroid.cpp src/model/LifeGui.cpp src/model/Entity.cpp src/model/Missile.cpp) target_link_libraries(GLE-test utils ${GLFW3_LIBRARIES} ${GLEW_LIBRARIES}) include/GlApplication.hpp +19 −0 Changes for include/GlApplication.hpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -18,10 +18,16 @@ #include "GuiElement.hpp" #include "RenderObject.hpp" #include "model/Asteroid.hpp" #include "model/LifeGui.hpp" #include "model/Missile.hpp" #include "model/Player.hpp" #include "model/Spaceship.hpp" #define WIN_NOT_WIN_YET -1 #define WIN_PLAYER_1 1 #define WIN_PLAYER_2 2 #define WIN_DRAW 3 class RenderObject; class GlApplication : public Application { Loading Loading @@ -51,9 +57,13 @@ class GlApplication : public Application { void createEntities(); void renderFrame() override; void renderGameFrame(); void renderGameEndedFrame(); void renderGUI(); void update() override; void updateGame(); void updateGameEnded(); static void resize(GLFWwindow * window, int framebufferWidth, int framebufferHeight); static void keyCallback(GLFWwindow * window, int key, int scancode, int action, int mods); void continuousKey(float deltaTime); Loading @@ -61,6 +71,8 @@ class GlApplication : public Application { void processPlayer1Input(GLFWwindow *window, float deltaTime); void processPlayer2Input(GLFWwindow *window, float deltaTime); void resetGame(); private: bool drawBoundingBoxes; Loading @@ -81,6 +93,13 @@ class GlApplication : public Application { std::shared_ptr<Spaceship> m_spaceshipPlayer1; ///< Player 1 spaceship std::shared_ptr<Spaceship> m_spaceshipPlayer2; ///< Player 2 spaceship std::shared_ptr<GuiElement> win; std::shared_ptr<GuiElement> lose; std::shared_ptr<GuiElement> draw; std::shared_ptr<LifeGui> healthbar; int winner; Program guiProgram; }; include/GuiElement.hpp +7 −1 Changes for include/GuiElement.hpp: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -15,15 +15,21 @@ class GuiElement { glm::vec2 dimension; Sampler textureSampler; Texture texture; std::shared_ptr<Texture> texture; VAO vao; glm::mat4 modelMatrix; void computeModelMatrix(); void createElement(Program &program); protected: void setTexture(std::shared_ptr<Texture> &newTexture); public: GuiElement(Program &program, const std::string &texturePath); GuiElement(Program &program); void setPosition(glm::vec2 position); Loading include/model/LifeGui.hpp 0 → 100644 +18 −0 Changes for include/model/LifeGui.hpp: 18 added lines, 0 removed lines. Original line number Diff line number Diff line #pragma once #include <glApi.hpp> #include "GuiElement.hpp" class LifeGui : public GuiElement { public: LifeGui(Program &program); void setCurrentLife(const unsigned int &life); private: std::shared_ptr<Texture> hp_3_texture; std::shared_ptr<Texture> hp_2_texture; std::shared_ptr<Texture> hp_1_texture; }; No newline at end of file meshes/draw.png 0 → 100644 +32.9 KiB Loading image diff... Loading
CMakeLists.txt +1 −1 Changes for CMakeLists.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -18,5 +18,5 @@ include_directories("glitter/ext/tinyobjloader" ${OPENGL_INCLUDE_DIR}) add_executable(GLE-test src/main.cpp src/RenderObject.cpp src/GuiElement.cpp src/RenderObjectPart.cpp src/GlApplication.cpp src/model/Spaceship.cpp src/model/Asteroid.cpp src/model/Entity.cpp src/model/Missile.cpp) src/model/Spaceship.cpp src/model/Asteroid.cpp src/model/LifeGui.cpp src/model/Entity.cpp src/model/Missile.cpp) target_link_libraries(GLE-test utils ${GLFW3_LIBRARIES} ${GLEW_LIBRARIES})
include/GlApplication.hpp +19 −0 Changes for include/GlApplication.hpp: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -18,10 +18,16 @@ #include "GuiElement.hpp" #include "RenderObject.hpp" #include "model/Asteroid.hpp" #include "model/LifeGui.hpp" #include "model/Missile.hpp" #include "model/Player.hpp" #include "model/Spaceship.hpp" #define WIN_NOT_WIN_YET -1 #define WIN_PLAYER_1 1 #define WIN_PLAYER_2 2 #define WIN_DRAW 3 class RenderObject; class GlApplication : public Application { Loading Loading @@ -51,9 +57,13 @@ class GlApplication : public Application { void createEntities(); void renderFrame() override; void renderGameFrame(); void renderGameEndedFrame(); void renderGUI(); void update() override; void updateGame(); void updateGameEnded(); static void resize(GLFWwindow * window, int framebufferWidth, int framebufferHeight); static void keyCallback(GLFWwindow * window, int key, int scancode, int action, int mods); void continuousKey(float deltaTime); Loading @@ -61,6 +71,8 @@ class GlApplication : public Application { void processPlayer1Input(GLFWwindow *window, float deltaTime); void processPlayer2Input(GLFWwindow *window, float deltaTime); void resetGame(); private: bool drawBoundingBoxes; Loading @@ -81,6 +93,13 @@ class GlApplication : public Application { std::shared_ptr<Spaceship> m_spaceshipPlayer1; ///< Player 1 spaceship std::shared_ptr<Spaceship> m_spaceshipPlayer2; ///< Player 2 spaceship std::shared_ptr<GuiElement> win; std::shared_ptr<GuiElement> lose; std::shared_ptr<GuiElement> draw; std::shared_ptr<LifeGui> healthbar; int winner; Program guiProgram; };
include/GuiElement.hpp +7 −1 Changes for include/GuiElement.hpp: 7 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -15,15 +15,21 @@ class GuiElement { glm::vec2 dimension; Sampler textureSampler; Texture texture; std::shared_ptr<Texture> texture; VAO vao; glm::mat4 modelMatrix; void computeModelMatrix(); void createElement(Program &program); protected: void setTexture(std::shared_ptr<Texture> &newTexture); public: GuiElement(Program &program, const std::string &texturePath); GuiElement(Program &program); void setPosition(glm::vec2 position); Loading
include/model/LifeGui.hpp 0 → 100644 +18 −0 Changes for include/model/LifeGui.hpp: 18 added lines, 0 removed lines. Original line number Diff line number Diff line #pragma once #include <glApi.hpp> #include "GuiElement.hpp" class LifeGui : public GuiElement { public: LifeGui(Program &program); void setCurrentLife(const unsigned int &life); private: std::shared_ptr<Texture> hp_3_texture; std::shared_ptr<Texture> hp_2_texture; std::shared_ptr<Texture> hp_1_texture; }; No newline at end of file