need to see the toreiller, sorry ! :D

This commit is contained in:
Lendemor 2016-05-17 23:26:39 +02:00
parent 2f95e0350c
commit d63e0a8fe6
6 changed files with 69 additions and 7 deletions

View File

@ -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)); memset(&m_memory,0,DUDE_MEMORY_SIZE*sizeof(char));
} }

View File

@ -10,11 +10,9 @@ private:
Info m_info; Info m_info;
bool m_dead; bool m_dead;
char m_memory[DUDE_MEMORY_SIZE]; char m_memory[DUDE_MEMORY_SIZE];
BehaviorFunction m_behavior;
public: public:
Dude(); Dude();
Dude(Coord,Info,bool,BehaviorFunction); Dude(Coord,Info);
}; };
#endif // DUDE_H #endif // DUDE_H

View File

@ -1,7 +1,24 @@
#include "simulation.h" #include "simulation.h"
Simulation::Simulation(Map *_map,std::vector<BehaviorFunction> _behaviors): Simulation::Simulation(Map *_map,std::vector<BehaviorFunction> _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();
}
} }

View File

@ -3,8 +3,9 @@
#include <vector> #include <vector>
#include <map>
#include "behavior.h" #include "behavior.h"
#include "team.h"
class Map; class Map;
@ -12,9 +13,10 @@ class Simulation
{ {
private: private:
Map *p_map; Map *p_map;
std::vector<BehaviorFunction> m_behaviors; std::map<int,Team> m_teams;
public: public:
Simulation(Map *_map,std::vector<BehaviorFunction> _behaviors); Simulation(Map *_map,std::vector<BehaviorFunction> _behaviors);
void run();
}; };
#endif // SIMULATION_H #endif // SIMULATION_H

16
src/team.cpp Normal file
View File

@ -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);
}

29
src/team.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef TEAM_H
#define TEAM_H
#include <vector>
#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<Dude> m_dudes;
BehaviorFunction m_behavior;
public:
Team();
Team(glm::vec3 _color,Coord _spawn,BehaviorFunction _behavior);
bool updateSpawn();
};
#endif // TEAM_H