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/Entity.cpp src/model/Missile.cpp src/model/Box.cpp) src/model/Spaceship.cpp src/model/Entity.cpp src/model/Missile.cpp) target_link_libraries(GLE-test utils ${GLFW3_LIBRARIES} ${GLEW_LIBRARIES}) include/model/Box.hppdeleted 100644 → 0 +0 −16 Changes for include/model/Box.hpp: 0 added lines, 16 removed lines. Original line number Diff line number Diff line #pragma once #include <glm/ext.hpp> #include "model/Entity.hpp" class Box { private: glm::vec3 scales; public: Box(glm::vec3 &scales); bool is_point_inside(glm::vec3 &point, glm::vec3 ¢er); }; include/model/Entity.hpp +3 −1 Changes for include/model/Entity.hpp: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ class Entity { void setScale(glm::vec3 scales); glm::mat4 get_box_model_matrix(std::unique_ptr<RenderObject> &renderObject) const; bool check_box_intersection() const; bool check_box_intersection(std::unique_ptr<RenderObject> &renderObjectThis, const Entity &other, std::unique_ptr<RenderObject> &renderObjectOther) const; protected: void computeModelMatrix(); Loading include/model/Spaceship.hpp +5 −0 Changes for include/model/Spaceship.hpp: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ class Spaceship : public Entity { Player playerNumber; bool thrusting; float fireCooldown; unsigned int healthPoints; public: Spaceship(const Player &playerNumber, const glm::mat4 &modelWorld); Loading @@ -19,12 +20,16 @@ class Spaceship : public Entity { const glm::vec3 &get_acceleration() const; const Player &get_player_number() const; const bool &is_thrusting() const; const unsigned int &get_health_points() const; void set_acceleration(const glm::vec3 &newAcceleration); void set_thrusting(const bool &newThrusting); void take_damage(); void update(const float &deltaTime) override; std::shared_ptr<Missile> generate_missile(); // TODO : REMOVE AND REPLACE Loading src/GlApplication.cpp +16 −0 Changes for src/GlApplication.cpp: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -169,6 +169,22 @@ void GlApplication::update() entity->update(deltaTime); } } for (int index = this->m_entities[ModelKeys::LASER_1].size()-1; index != -1; --index) { std::shared_ptr<Entity> missile = this->m_entities[ModelKeys::LASER_1].at(index); if (missile->check_box_intersection(this->m_models[ModelKeys::LASER_1], *this->m_entities[ModelKeys::SPACESHIP_2][0], this->m_models[ModelKeys::SPACESHIP_2])) { std::cout << "Player 1 hit player 2 !" << std::endl; this->m_entities[ModelKeys::LASER_1].erase(this->m_entities[ModelKeys::LASER_1].begin()+index); } } for (int index = this->m_entities[ModelKeys::LASER_2].size()-1; index != -1; --index) { std::shared_ptr<Entity> missile = this->m_entities[ModelKeys::LASER_2].at(index); if (missile->check_box_intersection(this->m_models[ModelKeys::LASER_2], *this->m_entities[ModelKeys::SPACESHIP_1][0], this->m_models[ModelKeys::SPACESHIP_1])) { std::cout << "Player 2 hit player 1 !" << std::endl; this->m_entities[ModelKeys::LASER_2].erase(this->m_entities[ModelKeys::LASER_2].begin()+index); } } } void GlApplication::computeView(Player player) Loading 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/Entity.cpp src/model/Missile.cpp src/model/Box.cpp) src/model/Spaceship.cpp src/model/Entity.cpp src/model/Missile.cpp) target_link_libraries(GLE-test utils ${GLFW3_LIBRARIES} ${GLEW_LIBRARIES})
include/model/Box.hppdeleted 100644 → 0 +0 −16 Changes for include/model/Box.hpp: 0 added lines, 16 removed lines. Original line number Diff line number Diff line #pragma once #include <glm/ext.hpp> #include "model/Entity.hpp" class Box { private: glm::vec3 scales; public: Box(glm::vec3 &scales); bool is_point_inside(glm::vec3 &point, glm::vec3 ¢er); };
include/model/Entity.hpp +3 −1 Changes for include/model/Entity.hpp: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ class Entity { void setScale(glm::vec3 scales); glm::mat4 get_box_model_matrix(std::unique_ptr<RenderObject> &renderObject) const; bool check_box_intersection() const; bool check_box_intersection(std::unique_ptr<RenderObject> &renderObjectThis, const Entity &other, std::unique_ptr<RenderObject> &renderObjectOther) const; protected: void computeModelMatrix(); Loading
include/model/Spaceship.hpp +5 −0 Changes for include/model/Spaceship.hpp: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ class Spaceship : public Entity { Player playerNumber; bool thrusting; float fireCooldown; unsigned int healthPoints; public: Spaceship(const Player &playerNumber, const glm::mat4 &modelWorld); Loading @@ -19,12 +20,16 @@ class Spaceship : public Entity { const glm::vec3 &get_acceleration() const; const Player &get_player_number() const; const bool &is_thrusting() const; const unsigned int &get_health_points() const; void set_acceleration(const glm::vec3 &newAcceleration); void set_thrusting(const bool &newThrusting); void take_damage(); void update(const float &deltaTime) override; std::shared_ptr<Missile> generate_missile(); // TODO : REMOVE AND REPLACE Loading
src/GlApplication.cpp +16 −0 Changes for src/GlApplication.cpp: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -169,6 +169,22 @@ void GlApplication::update() entity->update(deltaTime); } } for (int index = this->m_entities[ModelKeys::LASER_1].size()-1; index != -1; --index) { std::shared_ptr<Entity> missile = this->m_entities[ModelKeys::LASER_1].at(index); if (missile->check_box_intersection(this->m_models[ModelKeys::LASER_1], *this->m_entities[ModelKeys::SPACESHIP_2][0], this->m_models[ModelKeys::SPACESHIP_2])) { std::cout << "Player 1 hit player 2 !" << std::endl; this->m_entities[ModelKeys::LASER_1].erase(this->m_entities[ModelKeys::LASER_1].begin()+index); } } for (int index = this->m_entities[ModelKeys::LASER_2].size()-1; index != -1; --index) { std::shared_ptr<Entity> missile = this->m_entities[ModelKeys::LASER_2].at(index); if (missile->check_box_intersection(this->m_models[ModelKeys::LASER_2], *this->m_entities[ModelKeys::SPACESHIP_1][0], this->m_models[ModelKeys::SPACESHIP_1])) { std::cout << "Player 2 hit player 1 !" << std::endl; this->m_entities[ModelKeys::LASER_2].erase(this->m_entities[ModelKeys::LASER_2].begin()+index); } } } void GlApplication::computeView(Player player) Loading