From d63e0a8fe6a8826ae1993839213aef8a671c8610 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Tue, 17 May 2016 23:26:39 +0200 Subject: [PATCH] need to see the toreiller, sorry ! :D --- src/dude.cpp | 2 +- src/dude.h | 4 +--- src/simulation.cpp | 19 ++++++++++++++++++- src/simulation.h | 6 ++++-- src/team.cpp | 16 ++++++++++++++++ src/team.h | 29 +++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 src/team.cpp create mode 100644 src/team.h diff --git a/src/dude.cpp b/src/dude.cpp index 47feac4..9438c92 100644 --- a/src/dude.cpp +++ b/src/dude.cpp @@ -6,7 +6,7 @@ Dude::Dude() } -Dude::Dude(Coord _pos, Info _info, bool _dead, BehaviorFunction _behavior):m_pos(_pos),m_info(_info),m_dead(_dead),m_behavior(_behavior) +Dude::Dude(Coord _pos, Info _info):m_pos(_pos),m_info(_info),m_dead(false) { memset(&m_memory,0,DUDE_MEMORY_SIZE*sizeof(char)); } diff --git a/src/dude.h b/src/dude.h index e05aec1..4dc2bd0 100644 --- a/src/dude.h +++ b/src/dude.h @@ -10,11 +10,9 @@ private: Info m_info; bool m_dead; char m_memory[DUDE_MEMORY_SIZE]; - BehaviorFunction m_behavior; - public: Dude(); - Dude(Coord,Info,bool,BehaviorFunction); + Dude(Coord,Info); }; #endif // DUDE_H diff --git a/src/simulation.cpp b/src/simulation.cpp index db4c8c6..4d7eff9 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -1,7 +1,24 @@ #include "simulation.h" Simulation::Simulation(Map *_map,std::vector _behaviors): - p_map(_map),m_behaviors(_behaviors) + p_map(_map) { + int i=0; + for(auto behavior : _behaviors){ + glm::vec3 color; + color[i%3]=i*50; + Coord spawn; + m_teams[i] = Team(color,spawn,behavior); + i++; + } +} + +void Simulation::run() +{ + for(auto team : m_teams){ + // team.second.updateSpawn(); + + + } } diff --git a/src/simulation.h b/src/simulation.h index dba4f19..9a9daed 100644 --- a/src/simulation.h +++ b/src/simulation.h @@ -3,8 +3,9 @@ #include - +#include #include "behavior.h" +#include "team.h" class Map; @@ -12,9 +13,10 @@ class Simulation { private: Map *p_map; - std::vector m_behaviors; + std::map m_teams; public: Simulation(Map *_map,std::vector _behaviors); + void run(); }; #endif // SIMULATION_H diff --git a/src/team.cpp b/src/team.cpp new file mode 100644 index 0000000..eccda81 --- /dev/null +++ b/src/team.cpp @@ -0,0 +1,16 @@ +#include "team.h" + +Team::Team() +{ + +} + +Team::Team(glm::vec3 _color,Coord _spawn,BehaviorFunction _behavior): + m_color(_color),m_spawn(_spawn),m_spawnCooldown(SPAWN_COOLDOWN), + m_foodQuantity(NB_STARTING_FOOD), m_behavior(_behavior) +{ +} + +bool Team::updateSpawn(){ + return !(--m_spawnCooldown); +} diff --git a/src/team.h b/src/team.h new file mode 100644 index 0000000..6a4dd44 --- /dev/null +++ b/src/team.h @@ -0,0 +1,29 @@ +#ifndef TEAM_H +#define TEAM_H + +#include + +#include "glm/vec3.hpp" + +#include "coord.h" +#include "dude.h" +#include "behavior.h" + +#define NB_STARTING_FOOD 5 +#define SPAWN_COOLDOWN 30 + +class Team +{ + glm::vec3 m_color; + Coord m_spawn; + int m_spawnCooldown; + int m_foodQuantity; + std::vector m_dudes; + BehaviorFunction m_behavior; +public: + Team(); + Team(glm::vec3 _color,Coord _spawn,BehaviorFunction _behavior); + bool updateSpawn(); +}; + +#endif // TEAM_H