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