small change
This commit is contained in:
parent
3a888c53a6
commit
388794bca6
@ -23,9 +23,9 @@ Simulation::Simulation(MapScene *_map, std::vector<BehaviorFunction> &_behaviors
|
||||
void Simulation::update()
|
||||
{
|
||||
std::random_shuffle(m_dudes.begin(),m_dudes.end());
|
||||
//BUG : find segfault origin
|
||||
if(m_dudes.empty()){
|
||||
for (Dude* dude : m_dudes){
|
||||
//TODO FIX : find segfault origin
|
||||
if(!m_dudes.empty()){
|
||||
for (auto dude : m_dudes){
|
||||
auto action = m_teams[dude->getTeam()].update(dude); //get action for this dude from behavior function in team
|
||||
handleAction(action,dude);
|
||||
}
|
||||
@ -40,7 +40,6 @@ void Simulation::update()
|
||||
m_dudes.push_back(new Dude(spawnPos,p_map,i));
|
||||
}
|
||||
}
|
||||
// std::cerr << "Update..." << std::endl;
|
||||
}
|
||||
|
||||
// TODO finish conversion of handleAction()
|
||||
@ -49,6 +48,7 @@ void Simulation::handleAction(Action *action, Dude *dude){
|
||||
Pixel target = p_map->getPixel(targetPos);
|
||||
Dude* targetDude;
|
||||
dude->setSuccess(false);
|
||||
if(action == NULL) return;
|
||||
switch(action->type){
|
||||
case Action::MOVE:
|
||||
if (isWalkable(target.type))
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "team.h"
|
||||
#include "dude.h"
|
||||
|
||||
Team::Team(const glm::vec3 &teamColor, const glm::vec3 &dudeColor, BehaviorFunction _behavior):
|
||||
m_teamColor(teamColor),
|
||||
@ -32,8 +33,6 @@ void Team::destroySpawn(){
|
||||
Action* Team::update(Dude *dude)
|
||||
{
|
||||
Action* action;
|
||||
m_behavior(action,
|
||||
dude->getMemory(),
|
||||
(Info*) dude);
|
||||
m_behavior(action, dude->getMemory(),(Info*) dude);
|
||||
return action;
|
||||
}
|
||||
|
@ -6,12 +6,13 @@
|
||||
#include "glm/vec3.hpp"
|
||||
|
||||
#include "coord.h"
|
||||
#include "dude.h"
|
||||
#include "behavior.h"
|
||||
|
||||
#define NB_STARTING_FOOD 5
|
||||
#define SPAWN_COOLDOWN 30
|
||||
|
||||
class Dude;
|
||||
|
||||
class Team
|
||||
{
|
||||
glm::vec3 m_teamColor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user