traces working and nice (on simple renderer)
This commit is contained in:
parent
fd8d56bf95
commit
2b85397674
5 changed files with 26 additions and 12 deletions
|
@ -32,7 +32,7 @@ bool Game::cycle(float dt)
|
||||||
acc -= spawnInterval;
|
acc -= spawnInterval;
|
||||||
|
|
||||||
float a = 2.0 * M_PI * util::randf_0_1();
|
float a = 2.0 * M_PI * util::randf_0_1();
|
||||||
float speed = 0.002;
|
float speed = 0.005;
|
||||||
m_state->players[0]->addCommand(new game::ShootCommand(a, speed));
|
m_state->players[0]->addCommand(new game::ShootCommand(a, speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
|
|
||||||
|
#include "state/trace.hpp"
|
||||||
#include "state/object.hpp"
|
#include "state/object.hpp"
|
||||||
#include "state/missile.hpp"
|
#include "state/missile.hpp"
|
||||||
#include "state/player.hpp"
|
#include "state/player.hpp"
|
||||||
|
@ -41,6 +42,10 @@ protected:
|
||||||
drawPlanet(planet->position, planet->radius);
|
drawPlanet(planet->position, planet->radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const game::Trace *trace : m_game.state()->traces) {
|
||||||
|
drawTrace(trace);
|
||||||
|
}
|
||||||
|
|
||||||
for (const game::Ship *ship : m_game.state()->ships) {
|
for (const game::Ship *ship : m_game.state()->ships) {
|
||||||
drawShip(ship->position);
|
drawShip(ship->position);
|
||||||
}
|
}
|
||||||
|
@ -73,9 +78,18 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMissile(const glm::vec2 &pos)
|
void drawMissile(const glm::vec2 &pos)
|
||||||
|
|
||||||
{
|
{
|
||||||
glm::vec3 color = glm::vec3(1.0, 1.0, 0.3);
|
glm::vec3 color = glm::vec3(1.0, 1.0, 0.3);
|
||||||
m_renderer.drawCircle(pos.x, pos.y, 0.005, color.x, color.y, color.z, 5);
|
m_renderer.drawCircle(pos.x, pos.y, 0.01, color.x, color.y, color.z, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawTrace(const game::Trace *trace)
|
||||||
|
{
|
||||||
|
for (const game::Trace::TracePoint &p : trace->points) {
|
||||||
|
glm::vec3 color = glm::vec3(0.1, 0.3, 1.0) / (1.0f + 500.0f*p.speed);
|
||||||
|
m_renderer.drawCircle(p.position.x, p.position.y, 0.005, color.x, color.y, color.z, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -130,7 +130,7 @@ void endofthejedi::GLWindow::loop() {
|
||||||
prev = current;
|
prev = current;
|
||||||
if(delta > 0.0) {
|
if(delta > 0.0) {
|
||||||
m_fps = (1000000000.0/delta);
|
m_fps = (1000000000.0/delta);
|
||||||
std::cout << m_fps << "\n";
|
//std::cout << m_fps << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ endofthejedi::Renderer::Renderer() {
|
||||||
|
|
||||||
endofthejedi::Renderer::~Renderer() {}
|
endofthejedi::Renderer::~Renderer() {}
|
||||||
|
|
||||||
void endofthejedi::Renderer::drawCircle(float x, float y, float radius, float r,
|
void endofthejedi::Renderer::drawCircle(float x, float y, float radius, float r, float g, float b, int numSides)
|
||||||
float g, float b, int numSides) {
|
{
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
glVertex2f(x, y); // center of circle
|
|
||||||
for (int i = 0; i <= numSides; i++) {
|
|
||||||
glColor3f(r,g,b);
|
glColor3f(r,g,b);
|
||||||
glVertex2f(x + (radius * cos(i * 2 * M_PI / numSides)), y + (radius * sin(i * 2 * M_PI / numSides)));
|
glVertex2f(x, y); // center of circle
|
||||||
}
|
for (int i = 0; i <= numSides; i++) {
|
||||||
glEnd();
|
glVertex2f(x + (radius * cos(i * 2 * M_PI / numSides)), y + (radius * sin(i * 2 * M_PI / numSides)));
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace game {
|
||||||
void Trace::addPointFromMissile(bool forceAdd)
|
void Trace::addPointFromMissile(bool forceAdd)
|
||||||
{
|
{
|
||||||
fidelityCounter++;
|
fidelityCounter++;
|
||||||
if (forceAdd || fidelityCounter >= 20) {
|
if (forceAdd || fidelityCounter >= 10) {
|
||||||
fidelityCounter = 0;
|
fidelityCounter = 0;
|
||||||
points.push_back(TracePoint(missile));
|
points.push_back(TracePoint(missile));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue