From 959202e1116bca160ffd687f9d32973fb64bdc1b Mon Sep 17 00:00:00 2001 From: end Date: Wed, 28 Sep 2016 05:50:43 +0200 Subject: [PATCH] * some fixes --- game/renderer.cpp | 33 +++++++++++++++++++++++++++++++-- game/renderer.hpp | 4 ++++ game/state/state.cpp | 4 +--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/game/renderer.cpp b/game/renderer.cpp index c11a04d..31b6c46 100644 --- a/game/renderer.cpp +++ b/game/renderer.cpp @@ -29,12 +29,41 @@ void endofthejedi::Renderer::render(const game::State *state) { std::vector reflections; for (const game::Planet *planet : state->planets) { - positions.push_back(glm::vec3(planet->position, -10.0f)); + positions.push_back(glm::vec3(planet->position, -5.0f)); radii.push_back(planet->radius); colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); } - glUniform1f(m_shader.location("aspectratio"), 16.0f/9.0f); + for (const game::Ship *ship : state->ships) { + positions.push_back(glm::vec3(ship->position, -3.0f)); + radii.push_back(ship->radius); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + + for (const game::Player *player : state->players) { + for (const game::Missile *missile : player->missiles) { + positions.push_back(glm::vec3(missile->position, -3.0f)); + radii.push_back(0.01f); + colors.push_back(glm::vec4(1.0f, 0.0f, 0.0f, 0.5f)); + } + } + + for (auto& pos : positions) { + pos.x *= 5; + pos.y *= 5; + } + for (auto& rad : radii) { + rad *= 5; + } + + /* + for (const game::Trace *trace : state->traces) { + positions.push_back(glm::vec3(trace->position, -3.0f)); + radii.push_back(trace->radius); + colors.push_back(glm::vec4(0.0f, 1.0f, 0.0f, 0.5f)); + }*/ + + glUniform1f(m_shader.location("aspectratio"), 1.0f); glUniform1i(m_shader.location("reflections"), 1); glUniform3f(m_shader.location("l_position"), 0.6f, 0.1f, 0.0f); glUniform1f(m_shader.location("l_radius"), 1.0f); diff --git a/game/renderer.hpp b/game/renderer.hpp index 572547a..36275ae 100644 --- a/game/renderer.hpp +++ b/game/renderer.hpp @@ -8,6 +8,10 @@ #include "glclasses.hpp" #include "game.hpp" #include "state/planet.hpp" +#include "state/trace.hpp" +#include "state/player.hpp" +#include "state/ship.hpp" +#include "state/missile.hpp" namespace endofthejedi { diff --git a/game/state/state.cpp b/game/state/state.cpp index acce65c..d84364d 100644 --- a/game/state/state.cpp +++ b/game/state/state.cpp @@ -45,9 +45,7 @@ namespace game { } } while(glm::length(pos) < 0.2 && tries++ < 1000); - pos.x *= 10; - pos.y *= 10; - planets.push_back(new Planet(pos, (0.03 + 0.07*util::randf_0_1()) * 10)); + planets.push_back(new Planet(pos, 0.03 + 0.07*util::randf_0_1())); } }