From 84a9aad3e08bc70aee655985cc98d523ba2ad93c Mon Sep 17 00:00:00 2001 From: Anselme Date: Wed, 18 May 2016 17:50:22 +0200 Subject: [PATCH] fixes and added TODOs --- src/simulation.cpp | 8 ++++---- src/simulation.h | 8 ++++++-- src/team.cpp | 15 +++++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/simulation.cpp b/src/simulation.cpp index 03face5..8601d8a 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -2,19 +2,20 @@ #include "map.h" -Simulation::Simulation(Map *_map,std::vector _behaviors): +Simulation::Simulation(Map *_map, std::vector &_behaviors): p_map(_map) { int i=0; - for(auto behavior : _behaviors){ + for(BehaviorFunction &behavior : _behaviors){ glm::vec3 color; color[i%3]=0.5f*(1 + i/3); m_teams.push_back(Team(color, color, behavior)); i++; + // TODO : display the spawns on the map } } -void Simulation::run() +void Simulation::update() { for(int i=0; i m_teams; public: - Simulation(Map *_map, std::vector _behaviors); - void run(); + Simulation(Map *_map, std::vector &_behaviors); + + /** + * @brief update runs one step of simulation + */ + void update(); }; #endif // SIMULATION_H diff --git a/src/team.cpp b/src/team.cpp index d4ed590..25f7f58 100644 --- a/src/team.cpp +++ b/src/team.cpp @@ -12,13 +12,20 @@ Team::Team(const glm::vec3 &teamColor, const glm::vec3 &dudeColor, BehaviorFunct bool Team::updateSpawn() { if(m_foodQuantity > 0) - return !(--m_spawnCooldown); + { + --m_spawnCooldown; + if(!m_spawnCooldown) + { + m_spawnCooldown = SPAWN_COOLDOWN; + --m_foodQuantity; + return true; + } + } + return false; } void Team::spawn(Coord &d, Map &map) { - m_spawnCooldown = SPAWN_COOLDOWN; - --m_foodQuantity; m_dudes.push_back(Dude(d, map)); } @@ -27,6 +34,6 @@ void Team::updateDudes() for (Dude &dude : m_dudes){ Action* action; m_behavior(action, dude.getMemory(), &dude); - // TODO perform action + // TODO perform action (cf old_code/main.c -> void handleAction(t_dude* dude) ) } }