Commit 99d70925 authored by Pierre TESSIER's avatar Pierre TESSIER

Added score display

parent c864ba35
......@@ -44,6 +44,8 @@ void scene_model::frame_draw(std::map<std::string,GLuint>& shaders, scene_struct
if (m_gameOver)
{
std::cout << "Game Over" << std::endl;
std::cout << "Final score : " << m_score << std::endl;
std::cout << "Maximum wave reached : " << m_waveNumber << std::endl;
glfwSetWindowShouldClose(gui.window, GLFW_TRUE);
return;
}
......@@ -94,6 +96,7 @@ void scene_model::buildEntities(std::map<std::string,GLuint>& shaders)
builder.buildAICharacter(m_player, AIPosition, shaders);
m_nbAI = 2;
m_waveSize = 2;
m_waveNumber = 1;
m_aimCursor = m_ecs.createEntity();
m_ecs.add<TransformComponent>(m_aimCursor, vec3(0,0,2));
......@@ -110,6 +113,11 @@ void scene_model::set_gui()
ImGui::Spacing();
ImGui::SliderFloat("Time scale", &m_timer.scale, 0.1f, 3.0f);
std::ostringstream stream;
stream << "Score: " << m_score << ", Wave number " << m_waveNumber;
ImGui::Spacing();
ImGui::Text(stream.str().c_str());
}
void scene_model::logicLoop(std::map<std::string,GLuint>& shaders, scene_structure& scene, gui_structure& gui)
......@@ -154,10 +162,10 @@ void scene_model::logicLoop(std::map<std::string,GLuint>& shaders, scene_structu
m_ecs.update<HealthSystem>(m_ecs);
m_ecs.getSystem<HealthSystem>().destroyDeadCharacter(m_ecs, m_resources, m_score, m_nbAI);
std::cout << "score = " << m_score << " , nbAI = " << m_nbAI << " , wave_size = " << m_waveSize << std::endl;
if (m_nbAI == 0)
{
m_waveSize++;
m_waveNumber++;
createAI(shaders, m_waveSize);
}
}
......
#pragma once
#include <vector>
#include <sstream>
#include <iostream>
#include <string>
#include <ctime>
......@@ -79,6 +81,7 @@ private:
int m_score;
int m_nbAI;
int m_waveSize;
int m_waveNumber;
bool m_gameOver = false;
Skybox m_skybox;
......
......@@ -95,7 +95,7 @@ ecs::Entity EntityBuilder::buildPlayer(vcl::vec3 const& position, std::map<std::
ecs::Entity EntityBuilder::buildAICharacter(ecs::Entity const target, vcl::vec3 const& position, std::map<std::string,GLuint>& shaders)
{
auto& hierarchyPair = m_resources.AIHierarchyPool.getFreeElement();
auto hierarchyPair = m_resources.AIHierarchyPool.getFreeElement();
auto& hierarchy = hierarchyPair.first;
ecs::Entity ai = buildCharacter(m_resources.standardCharacter, hierarchy, position, shaders);
m_ecs.add<CharacterDesignComponent>(ai, 3.0f, 1.0f);
......
......@@ -11,7 +11,7 @@ struct HealthSystem
{
public:
void update(MyEcs& myEcs, RayComponent& ray);
void HealthSystem::destroyDeadCharacter(MyEcs& myEcs, CommonSceneResources& ressources, int& score, int& nbAI);
void destroyDeadCharacter(MyEcs& myEcs, CommonSceneResources& ressources, int& score, int& nbAI);
using Requirements = ecs::Requirements<ecs::Auto>;
using UpdatePolicy = ecs::OncePerEntity;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment