need to see the toreiller, sorry ! :D
This commit is contained in:
parent
2f95e0350c
commit
d63e0a8fe6
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,24 @@
|
||||
#include "simulation.h"
|
||||
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <map>
|
||||
#include "behavior.h"
|
||||
#include "team.h"
|
||||
|
||||
class Map;
|
||||
|
||||
@ -12,9 +13,10 @@ class Simulation
|
||||
{
|
||||
private:
|
||||
Map *p_map;
|
||||
std::vector<BehaviorFunction> m_behaviors;
|
||||
std::map<int,Team> m_teams;
|
||||
public:
|
||||
Simulation(Map *_map,std::vector<BehaviorFunction> _behaviors);
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif // SIMULATION_H
|
||||
|
16
src/team.cpp
Normal file
16
src/team.cpp
Normal 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
29
src/team.h
Normal 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
|
Loading…
x
Reference in New Issue
Block a user