Commit f1c733e1 authored by Justine Martin's avatar Justine Martin 💖
Browse files

feat : Génère les astéroides de manière aléatoire

parent f8c14c89
Loading
Loading
Loading
Loading
+2 −0
Changes for include/GlApplication.hpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@

#include <iostream>
#include <memory>
#include <cstdlib>
#include <ctime>

#include "GuiElement.hpp"
#include "RenderObject.hpp"
+2 −1
Changes for include/model/Entity.hpp: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@

class Entity {
    public:
        glm::vec3 m_position;
        
        Entity();
        virtual void update(const float &time);

@@ -35,7 +37,6 @@ class Entity {

        glm::mat4 m_modelMatrix;

        glm::vec3 m_position;
        glm::quat m_rotation;
        glm::vec3 m_scale;

+4 −0
Changes for src/GlApplication.cpp: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ GlApplication::GlApplication(int windowWidth, int windowHeight)
          m_spaceshipPlayer1(new Spaceship(Player::one, glm::mat4(1))),
          m_spaceshipPlayer2(new Spaceship(Player::two, glm::translate(glm::mat4(1), {0, 2, 2})))
{
    srand(time(NULL));
    GLFWwindow * window = glfwGetCurrentContext();
    glfwGetFramebufferSize(window, &windowWidth, &windowHeight);
    resize(window, windowWidth, windowHeight);
@@ -65,9 +66,12 @@ void GlApplication::createEntities() {

    const float pi = glm::pi<float>();

    for(int i = 0 ; i < 150 ; i++) {
        std::shared_ptr<Entity> asteroidEntity(new Asteroid());
        asteroidEntity->setScale(0.25);
        asteroidEntity->move({rand() % 80 - 45, rand() % 80 - 45, rand() % 80 - 45});
        m_entities[ModelKeys::ASTEROID].push_back(asteroidEntity);
    }

    /*std::shared_ptr<Entity> plankEntity(new Entity());
    plankEntity->move({2, 1, -0.1});
+0 −2
Changes for src/model/Asteroid.cpp: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,8 +2,6 @@

Asteroid::Asteroid()
        : Entity() {
    srand(time(NULL));

    const float pi = glm::pi<float>();
    this->rotationAngle = glm::vec3(glm::radians((float)(rand() % 180)) - pi, glm::radians((float)(rand() % 180)) - pi, glm::radians((float)(rand() % 180)) - pi);
}