int resetVisited(Element *e){ if (e->type() == "source"){ Source *s = (Source *)e; s->pin()->visited(false); } else if (e->type() == "ground"){ Ground *g = (Ground *)e; g->pin()->visited(false); } else if (e->type() == "resistor"){ Resistor *r = (Resistor *)e; r->pin("p0")->visited(false); r->pin("p1")->visited(false); } else if (e->type() == "switch"){ Switch *r = (Switch *)e; r->pin("p0")->visited(false); r->pin("p1")->visited(false); r->pin("in")->visited(false); } else if (e->type() == "bridge"){ Bridge *b = (Bridge *)e; b->in()->visited(false); b->out()->visited(false); } else if (e->type() == "meter"){ Meter *g = (Meter *)e; g->pin()->visited(false); } else{ cerr << "Unknown element: "<< e->info()<<endl; } return 0; }
void RoboMiner::move(int cy, int cx) { Ground *gr = frame->getGround(); int maxCell_x = gr->getCols(); int maxCell_y = gr->getRows(); if(cx<0 || cx>=maxCell_x) return; if(cy<0 || cy>=maxCell_y) return; /* std::cout << "Moving from (" << cell_y << "," << cell_x << ")" << " Cell(" << cell->getY() << "," << cell->getX() << ")" << " to (" << cy << "," << cx << ") with max_y: " << maxCell_y << " max_x: " << maxCell_x << std::endl; */ Cell *destcell = &(gr->getCell(cy, cx)); if(!destcell->isDrilled()) drill(cy, cx); if(destcell->isDrilled()){ cell->clearMiner(); cell = destcell; cell->hasMiner(this); cell_y = cy; cell_x = cx; energy -= 1; } }
IEntity* GroundFactory::create(const EntityProperties& properties) { b2BodyDef bodyDef = b2BodyDef(); bodyDef.position.Set(pixel2meter(properties.x), pixel2meter(properties.y)); bodyDef.angle = radian2degree(properties.angle); bodyDef.type = b2_staticBody; b2Body *body = GameWorld::getInstance()->getPhysicsWorld()->CreateBody(&bodyDef); b2PolygonShape polygonShape; polygonShape.SetAsBox(pixel2meter(properties.width / 2), pixel2meter(properties.height / 2)); b2FixtureDef fixtureDef; fixtureDef.shape = &polygonShape; fixtureDef.density = properties.density; fixtureDef.friction = properties.friction; fixtureDef.restitution = properties.restitution; fixtureDef.filter.categoryBits = COLLISION_BIT_GROUND; fixtureDef.filter.maskBits = COLLISION_BIT_BLOBBY | COLLISION_BIT_WEAPON | COLLISION_BIT_GROUND | COLLISION_BIT_OBJECT | COLLISION_BIT_BULLET; body->CreateFixture(&fixtureDef); body->ResetMassData(); Ground *ground = new Ground(); ground->addBody(body); return ground; }
/************************************* * All the interesting work happens here, when * I get called back from OpenGL to draw a frame. * When I am finished drawing, then the graphics * engine will wait until the proper amount of * time has passed and put the drawing on the screen. **************************************/ void callBack(const Interface *pUI, void *p) { Ground *pGround = (Ground *)p; if (pUI->isSpace()) pGround->generateGround(); pGround->draw(); }
void Ant::directMove(Ground& ground) { switch ((*move_distribution)(*gen)) { case 0: if (ground.checkifInGround(x - 1, y - 1)) { --x; --y; } break; case 1: if (ground.checkifInGround(x, y - 1)) { --y; } break; case 2: if (ground.checkifInGround(x + 1, y - 1)) { --y; ++x; } break; case 3: if (ground.checkifInGround(x - 1, y)) { --x; } break; case 4: if (ground.checkifInGround(x + 1, y)) { ++x; } break; case 5: if (ground.checkifInGround(x - 1, y + 1)) { --x; ++y; } break; case 6: if (ground.checkifInGround(x, y + 1)) { ++y; } break; case 7: if (ground.checkifInGround(x + 1, y + 1)) { ++x; ++y; } break; default: throw new UnexpectedException("Random number is outside range!"); } }
int main(int argc, char *argv[]) { // Initialize framework and bring up window arMasterSlaveFramework framework; if ( !framework.init( argc, argv ) ) { std::cerr << "Failed to init framework!" << std::endl; return -1; } framework.setNavTransSpeed( 0 ); framework.setNavRotSpeed( 0 ); primary.setDrawCallback( &drawRighthand ); secondary.setDrawCallback( &drawLefthand ); ground.init(); framework.setStartCallback( initSceneGraph ); framework.setDrawCallback( doSceneGraph ); framework.setPreExchangeCallback( onPreExchange ); return framework.start() ? 0 : 1; // Return 0 if framework.start exits ok return 0; }
void Game::init() { Global::init(); rend = Global::getRenderer(); Ground* g = new Ground(); g->setZ(0); _objects.push_back(g); Character* me = new Character(); me->setPosition(GETWINDOWWIDTH() / 2, GETWINDOWHEIGHT() / 2); me->setZ(1); _objects.push_back(me); MAINCAMERA()->setMe(me); }
void Init() { setupLights(); ground.Init(); for (int i = 0; i < 20; i++) { obstacles[i].Init(); } }
bool Ant::move(Ground& ground) { --time; //first fight std::list<Ant*> ants_near = ground.findAntsNextTo(x, y, id); if (!ants_near.empty()) { return fight(ants_near.front()); } if (move_function == nullptr) //ant just go out nest { move_function = &Ant::freeMove; } else if (food == can_carry_food) //and is going to nest, no matter what happen { move_function = &Ant::goToNest; } else if (food != can_carry_food && ground.isFood(x, y)) //on food field { move_function = &Ant::getFood; } else if (time < 0) //out of stamina ;] { move_function = &Ant::goToNest; make_path = false; } else if (ground.isSmell(x, y, id)) //smell { move_function = &Ant::followSmell; } (this->*move_function)(ground); last_x = x; last_y = y; if (x == nest_x && y == nest_y) //going into nest { move_function = nullptr; time_in_nest = nest_time_distribution(*gen); return false; } return true; }
void loadIsland() { float x, z; for(int i = 0; i < game_map.getStageMap().size(); i++) { for(int j = 0; j < game_map.getStageMap().at(i).size(); j++) { A_RGB rgb = game_map.getStageMap().at(i).at(j); if(rgb.isBlack()) { Ground hole = Ground(i,j); hole.getPosition().convert_to_xz(&x, &z); glPushMatrix(); glTranslatef(x,-0.5f,z); glScalef(0.5f,0.5f,0.5f); glmDraw(cube_hole, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); glPopMatrix(); } else if(rgb.isGreen()) { Ground floor = Ground(i,j); floor.getPosition().convert_to_xz(&x, &z); glPushMatrix(); glTranslatef(x,-0.5f,z); glScalef(0.5f,0.5f,0.5f); glmDraw(cube, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); glPopMatrix(); } else if(rgb.isRed()) { Ground crack = Ground(i,j); crack.getPosition().convert_to_xz(&x, &z); A_RGB east = game_map.getStageMap().at(i).at(j+1); A_RGB west = game_map.getStageMap().at(i).at(j-1); if(east.isRed() || west.isRed()) { glPushMatrix(); glTranslatef(x,-0.5f,z); glRotatef(90.0f, 0.0f, 1.0f, 0.0f); glScalef(0.5f,0.5f,0.5f); glmDraw(cube_crack, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); glPopMatrix(); } else { glPushMatrix(); glTranslatef(x,-0.5f,z); glScalef(0.5f,0.5f,0.5f); glmDraw(cube_crack, GLM_SMOOTH | GLM_MATERIAL | GLM_TEXTURE); glPopMatrix(); } } } } }
void Draw() { glLightfv(GL_LIGHT0, GL_POSITION, suns[0].direction); glLightfv(GL_LIGHT1, GL_POSITION, suns[1].direction); glLightfv(GL_LIGHT2, GL_POSITION, suns[2].direction); ground.Draw(); for (int i = 0; i < 20; i++) { obstacles[i].Draw(); } }
/** Draw the scene. */ void draw() { // The lights must be drawn FIRST, so the other scene elements // can get lit! pointLight.draw(); directionalLight.draw(); // Draw robot arm //robotArm.draw(); worm1.draw(); worm2.draw(); ground.draw(); mushroom1.draw(); mushroom2.draw(); }
void Rigidbody::update() { force.position.x *= 0.8f; force.position.z *= 0.8f; force.position.y -= 0.01568f; Transform trans(*(parent->getTransform())); trans.position += force.position; Ground* ground = (Ground*)(Central::getInst()->findObject("ground")); float ground_height = (ground->getHeight(&trans.position)); if(ground_height > trans.position.y) { trans.position.y = ground_height; force.position.y = 0; is_grounded = true; } else { is_grounded = false; } trans.rotate += force.rotate; if(force.rotate.w) { force.rotate.w *= 0.9f; } parent->setTransform(&trans); }
void Ant::freeMove(Ground& ground) { Direction tmp; if ((tmp = ground.findFoodNextTo(x, y)) != Direction::NO_DIRECTION) { goToDirectionNoCheck(tmp); return; } createMoveDistribution(ground); directMove(ground); //check if some enemy is near. }
void drawScene(void) { glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glEnable(GL_LIGHTING); // set up the scene pool.render(); basin.render(); ground.render(); // sky glDisable(GL_LIGHTING); skybox.render(); // water in the air glDisable(GL_TEXTURE_2D); glColor4fv(WATER_COLOR); fountain.render(); glEnable(GL_LIGHTING); glDisable(GL_BLEND); }
/** Construct the scene */ Scene() : // You have to call the parent class's constructor, to provide a // name for the model. Model("Scene"), worm1("1"), worm2("2"), ground(), mushroom1("1"), mushroom2("2"), // Construct textures and shaders. // They won't be loaded until the model is drawn for the first time. texture("checkers.png"), shader("shader.vert", "shader.frag", NULL), // Call the constructors for the lights pointLight("Point Light", GL_LIGHT1, /**direction part**/ -5, 5, 5, /**diffuse part**/ 1.0, 0.5, 0.5, /**specular part**/ 1.0, 0.5, 0.5, /**ambient part**/ .2f, 0.1, 0.1 /**attenuation part**/, 0.4, 0.7, 0), directionalLight("Directional Light", GL_LIGHT0, /**direction part**/ 5, 5, 5, /**diffuse part**/ 0.0f, 0.5, 0.5f, /**specular part**/ 0.0f, 0.5f, 0.5f ) // Now, call the constructors for each Property: { // If you have child Models, like the MobileLight model from model.h, // you can add their property groups, and they will appear in the list // in the top left corner of Modeler, under this model's entry: properties.add(pointLight.getProperties()) .add(directionalLight.getProperties()); properties.add(robotArm.getProperties()) .add(worm1.getProperties()) .add(worm2.getProperties()) .add(ground.getProperties()) .add(mushroom1.getProperties()) .add(mushroom2.getProperties()); // Finally, add all the properties to this model's PropertyGroup. }
/** * Apply the actuator force to BodyA and BodyB. * * @param s current SimTK::State */ void PointToPointActuator::computeForce(const SimTK::State& s, SimTK::Vector_<SimTK::SpatialVec>& bodyForces, SimTK::Vector& generalizedForces) const { const bool pointsAreGlobal = getPointsAreGlobal(); const SimTK::Vec3& pointA = getPointA(); const SimTK::Vec3& pointB = getPointB(); if(!_model) return; if( !_bodyA || !_bodyB ) return; // Get pointA and pointB positions in both the global frame, and in // the local frame of bodyA and bodyB, respectively. Points may have // been supplied either way. SimTK::Vec3 pointA_inGround, pointB_inGround, pointA_inBodyA, pointB_inBodyB; Ground ground = getModel().getGround(); if (pointsAreGlobal) { pointA_inGround = pointA; pointB_inGround = pointB; pointA_inBodyA = ground.findStationLocationInAnotherFrame(s, pointA_inGround, *_bodyA); pointB_inBodyB = ground.findStationLocationInAnotherFrame(s, pointB_inGround, *_bodyB); } else { pointA_inBodyA = pointA; pointB_inBodyB = pointB; pointA_inGround = _bodyA->findStationLocationInGround(s, pointA_inBodyA); pointB_inGround = _bodyB->findStationLocationInGround(s, pointB_inBodyB); } // Find the direction along which the actuator applies its force. // NOTE: this will fail if the points are coincident. const SimTK::Vec3 r = pointA_inGround - pointB_inGround; const SimTK::UnitVec3 direction(r); // normalize // Find the force magnitude and set it. Then form the force vector. double forceMagnitude; if (isActuationOverridden(s)) { forceMagnitude = computeOverrideActuation(s); } else { forceMagnitude = computeActuation(s); } setActuation(s, forceMagnitude); const SimTK::Vec3 force = forceMagnitude*direction; // Apply equal and opposite forces to the bodies. applyForceToPoint(s, *_bodyA, pointA_inBodyA, force, bodyForces); applyForceToPoint(s, *_bodyB, pointB_inBodyB, -force, bodyForces); // Get the relative velocity of the points in ground. SimTK::Vec3 velA_G = _bodyA->findStationVelocityInGround(s, pointA_inBodyA); SimTK::Vec3 velB_G = _bodyB->findStationVelocityInGround(s, pointB_inBodyB); SimTK::Vec3 velAB_G = velA_G-velB_G; // Speed used to compute power is the speed along the line connecting // the two bodies. setSpeed(s, ~velAB_G*direction); }
void display() { Ground *grtound = new Ground(); grtound->drawGround(); delete grtound; }
void RoboMiner::scan() { int radius = 6; int up_radius = radius, down_radius = radius; int left_radius = radius, right_radius = radius; int xdist, ydist; Ground *g = frame->getGround(); if(cell_x + right_radius >= g->getCols()) right_radius = g->getCols()-1-cell_x; if(cell_x - left_radius < 0) left_radius = cell_x; if(cell_y + down_radius >= g->getRows()) down_radius = g->getRows()-1-cell_y; if(cell_y - up_radius < 0) up_radius = cell_y; std::vector<Cell *> scope; // std::cout << "scan from (" << cell_y << "," << cell_x // << ")" << std::endl; for(xdist=-left_radius; xdist<=right_radius; ++xdist){ for(ydist=-up_radius; ydist<=down_radius; ++ydist){ if((abs(ydist)+abs(xdist))>radius) continue; if(ydist==0 && xdist==0) continue; Cell& scan_cell = g->getCell(cell_y+ydist, cell_x+xdist); scope.push_back(&scan_cell); } } /* std::cout << "\ty_r: " << y_radius << " x_r: " << x_radius << " tc: " << scope.size() << std::endl; for(auto& c: scope){ c->setVisible(true); if(c->mineralCount()){ mineralCells.push_back(c); } } */ std::vector<const Cell *> mineralCells; std::copy_if(scope.cbegin(), scope.cend(), std::back_inserter(mineralCells), \ [](Cell *c){ c->setVisible(true); return c->mineralCount(); }); if(mineralCells.empty() && !destCell){ int roll = rand() % 4; int x_off=0, y_off=0; switch(roll){ case 0: y_off = -up_radius; break; case 1: x_off = right_radius; break; case 2: y_off = down_radius; break; case 3: x_off = -left_radius; break; } // std::cout << "Exploring to: (" << cell_y+y_off // << "," << cell_x+x_off << ")" << std::endl; setDestination(cell_y + y_off, cell_x + x_off); exploring = true; }else if(!mineralCells.empty() && !destCell){ exploring = false; int roll = rand() % mineralCells.size(); const Cell *const hasMinerals = mineralCells[roll]; setDestination(hasMinerals->getY(), hasMinerals->getX()); } }
void RoboMiner::navigate() { int dest_y = destCell->getY(); int dest_x = destCell->getX(); int y_off = cell_y - dest_y; int x_off = cell_x - dest_x; int move_x = 0, move_y = 0; Ground *g = frame->getGround(); Cell& up = g->getCell((cell_y-1 >= 0 ? cell_y-1 : 0), cell_x); Cell& down = g->getCell((cell_y+1 < g->getRows() ? cell_y+1 : g->getRows()-1), cell_x); Cell& right = g->getCell(cell_y, (cell_x+1 < g->getCols() ? cell_x+1 : g->getCols()-1)); Cell& left = g->getCell(cell_y, (cell_x-1 >= 0 ? cell_x-1 : 0)); if(y_off > 0){ if(x_off > 0){ if(left.isDrilled()){ move_x = -1; goto done; } }else if(x_off < 0){ if(right.isDrilled()){ move_x = 1; goto done; } } move_y = -1; }else if(y_off < 0){ if(x_off > 0){ if(left.isDrilled()){ move_x = -1; goto done; } }else if(x_off < 0){ if(right.isDrilled()){ move_x = 1; goto done; } } move_y = 1; }else if(x_off > 0){ if(y_off > 0){ if(up.isDrilled()){ move_y = -1; goto done; } }else if(y_off < 0){ if(down.isDrilled()){ move_y = 1; goto done; } } move_x = -1; }else if(x_off < 0){ if(y_off > 0){ if(up.isDrilled()){ move_y = -1; goto done; } }else if(y_off < 0){ if(down.isDrilled()){ move_y = 1; goto done; } } move_x = 1; } done: move(cell_y + move_y, cell_x + move_x); if(dest_y == cell_y && dest_x == cell_x){ destCell = nullptr; if(atBase()){ ascending = true; } if(lastMinedOre){ setDestination(lastMinedOre->getY(), lastMinedOre->getX()); lastMinedOre = nullptr; } } }
void ContactListener::BeginContact(b2Contact* contact) { SceneNode* A = static_cast<SceneNode*> (contact -> GetFixtureA() -> GetBody() -> GetUserData() ); SceneNode* B = static_cast<SceneNode*> (contact -> GetFixtureB() -> GetBody() -> GetUserData() ); if (A -> getCategory() == Category::Projectile && contact->IsTouching()) { Projectile* proj = static_cast<Projectile*>(A); proj->isDead = true; } if (B -> getCategory() == Category::Projectile && contact->IsTouching()) { Projectile* proj = static_cast<Projectile*>(B); proj->isDead = true; } if (contact->IsTouching() && //projectile - ground (A -> getCategory() == Category::Projectile || B -> getCategory() == Category::Projectile) && (A -> getCategory() == Category::Ground || B -> getCategory() == Category::Ground)) { Ground* ground = static_cast<Ground*>( (A -> getCategory() == Category::Ground) ? A : B); Projectile* proj = static_cast<Projectile*>( (A -> getCategory() == Category::Ground) ? B : A ); if (proj->getType() == Projectile::Type::Missle) ground->explosion(proj->position, 3); } if (contact->IsTouching() && //player - ground (A -> getCategory() == Category::Player || B -> getCategory() == Category::Player) && (A -> getCategory() == Category::Ground || B -> getCategory() == Category::Ground)) { Player* player = static_cast<Player*>( (A -> getCategory() == Category::Ground) ? B : A ); player -> onFloor++; } if (contact->IsTouching() && //player - wreck (A -> getCategory() == Category::Player || B -> getCategory() == Category::Player) && (A -> getCategory() == Category::Wreck || B -> getCategory() == Category::Wreck)) { Player* player = static_cast<Player*>( (A -> getCategory() == Category::Wreck) ? B : A ); player -> onFloor++; } if (contact->IsTouching() && //projectile - enemy (A -> getCategory() == Category::Projectile || B -> getCategory() == Category::Projectile) && (A -> getCategory() == Category::Enemy || B -> getCategory() == Category::Enemy)) { Enemy* enemy = static_cast<Enemy*>( (A -> getCategory() == Category::Enemy) ? A : B); Projectile* proj = static_cast<Projectile*>( (A -> getCategory() == Category::Enemy) ? B : A ); enemy->hp -= proj->Table[proj->getType()].Damage; if (enemy->hp <= 0) { enemy -> isDead = true; } } if (contact->IsTouching() && //player - enemy (A -> getCategory() == Category::Player || B -> getCategory() == Category::Player) && (A -> getCategory() == Category::Enemy || B -> getCategory() == Category::Enemy)) { Player* player = static_cast<Player*>( (A -> getCategory() == Category::Enemy) ? B : A ); player->isHurting = true; } }
void Ant::getFood(Ground& ground) { food += ground.getFoodFromField(x, y, can_carry_food - food); make_path = ground.isFood(x, y); move_function = &Ant::goToNest; }
/* vector of achievements that match the achievements in the sql table(read the information for each one in from the table at the start?). check for achievement condition and whether achievement already unlocked before awarding the achievement(write to table) read in from table every so often or all time to check unlocked achievements? maybe just after an achievement is unlocked, should give the most up to date info */ int main() { thread reader1(std::bind(processReader, 1)); thread w(std::bind(processWriter, "Shoot!")); // Create the main window sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Semaphore Implementation"); window.setVerticalSyncEnabled(true); sf::Texture backgroundTexture; backgroundTexture.loadFromFile("Assets/background.png"); sf::Sprite background; background.setTexture(backgroundTexture); background.setPosition(0, 0); //load a font sf::Font font; font.loadFromFile("C:\\Windows\\Fonts\\GARA.TTF"); AchievementTracker* achievementTracker = new AchievementTracker(font); achievementTracker->LoadAchievements(); sf::Text currentWeaponText; currentWeaponText.setFont(font); currentWeaponText.setString("Current Weapon: "); currentWeaponText.setPosition(25, 25); currentWeaponText.setColor(sf::Color::Red); Player* player = new Player(); Ground* ground = new Ground(); Command* jumpCommand = new JumpCommand(player); Command* fireCommand = new FireCommand(player); Command* swapWeaponCommand = new SwapWeaponCommand(player); Command* lurchIneffectivelyCommand = new LurchIneffectivelyCommand(player); // Start game loop while (window.isOpen()) { // Process events sf::Event Event; while (window.pollEvent(Event)) { // Close window : exit if (Event.type == sf::Event::Closed) window.close(); // Escape key : exit if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape)) window.close(); if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Space)) { jumpCommand->Execute(); } if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::F)) { fireCommand->Execute(); shot = true; } if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::I)) { swapWeaponCommand->Execute(); } if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::L)) { lurchIneffectivelyCommand->Execute(); } } //prepare frame window.clear(); if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { player->setCurrentDirection(0); player->setMove(true); } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { player->setCurrentDirection(1); player->setMove(true); } else player->setMove(false); player->Update(); player->CheckCollisionWithGround(ground->getGlobalBounds()); if (player->getCurrentWeapon() == 0) currentWeaponText.setString("Current Weapon: Pistol"); else if (player->getCurrentWeapon() == 1) currentWeaponText.setString("Current Weapon: Rockets"); window.draw(background); window.draw(currentWeaponText); window.draw(*ground); player->Draw(window); window.draw(*player); achievementTracker->DisplayAchievement(window); // Finally, display rendered frame on screen window.display(); } //loop back for next frame return EXIT_SUCCESS; }
void Ant::goToNest(Ground& ground) { //leave smell // if (food) // { //// ground.makeSmell(x, y, id); // ground.makeSmell(x, y, id, getDirectionFromDifferenceSigns(x - last_x, y - last_y)); // } Direction act_direction = getDirectionFromDifferenceSigns(nest_x - x, nest_y - y); if (move_distribution != nullptr) { delete move_distribution; } switch (act_direction) { case Direction::UL: move_distribution = new std::discrete_distribution<> ({2, 1, 0, 1, 0, 0, 0, 0}); break; case Direction::UR: move_distribution = new std::discrete_distribution<> ({0, 1, 2, 0, 1, 0, 0, 0}); break; case Direction::U: move_distribution = new std::discrete_distribution<> ({1, 2, 1, 0, 0, 0, 0, 0}); break; case Direction::DL: move_distribution = new std::discrete_distribution<> ({0, 0, 0, 1, 0, 2, 1, 0}); break; case Direction::DR: move_distribution = new std::discrete_distribution<> ({0, 0, 0, 0, 1, 0, 1, 2}); break; case Direction::D: move_distribution = new std::discrete_distribution<> ({0, 0, 0, 0, 0, 1, 2, 1}); break; case Direction::L: move_distribution = new std::discrete_distribution<> ({1, 0, 0, 2, 0, 1, 0, 0}); break; case Direction::R: move_distribution = new std::discrete_distribution<> ({0, 0, 1, 0, 2, 0, 0, 1}); break; case Direction::NO_DIRECTION: move_distribution = new std::discrete_distribution<> ({1, 1, 1, 1, 1, 1, 1, 1}); break; } directMove(ground); if (make_path) { // ground.makeSmell(x, y, id); ground.makeSmell(x, y, id, getDirectionFromDifferenceSigns(last_x - x, last_y - y)); } // //for now it's closest way // if (x > nest_x && ground.checkifInGround(x - 1, y)) // { // --x; // } // if (x < nest_x && ground.checkifInGround(x + 1, y)) // { // ++x; // } // // if (y > nest_y && ground.checkifInGround(x, y - 1)) // { // --y; // } // if (y < nest_y && ground.checkifInGround(x, y + 1)) // { // ++y; // } }
void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glm::mat4 ViewMatrix; glm::vec3 cameraPos; glm::vec3 fpLookat; switch (camNum) { case 1://normal benhind copter rotates with copter cameraPos = glm::vec3(0, -8, 35); cameraPos = copter.position - glm::rotate(cameraPos, spinY, glm::vec3(0, 1, 0)); ViewMatrix = glm::lookAt(cameraPos, copter.position, glm::vec3(0, 1, 0)); break; case 2://birdseye cameraPos = glm::vec3(0,-60,1); cameraPos = copter.position - glm::rotate(cameraPos, spinY, glm::vec3(0, 1, 0)); ViewMatrix = glm::lookAt(cameraPos, copter.position, glm::vec3(0, 1, 0)); break; case 3://first person fpLookat = glm::vec3(0, -5, -60); fpLookat = copter.position - glm::rotate(fpLookat, spinY, glm::vec3(0, 1, 0)); cameraPos = glm::vec3(0, 0, -25); //cameraPos = glm::rotate(cameraPos, -tiltZ, glm::vec3(1, 0, 0)); //cameraPos = glm::rotate(cameraPos, -tiltX, glm::vec3(0, 0, 1)); cameraPos = copter.position - glm::rotate(cameraPos, spinY, glm::vec3(0, 1, 0)); ViewMatrix = glm::lookAt(cameraPos, fpLookat, glm::vec3(0, 1, 0)); break; case 4://side view cameraPos = glm::vec3(50, 0, 1); cameraPos = copter.position - glm::rotate(cameraPos, spinY, glm::vec3(0, 1, 0)); ViewMatrix = glm::lookAt(cameraPos, copter.position, glm::vec3(0, 1, 0)); break; case 5://cinematic cameraPos = glm::vec3(100, 100, 100); ViewMatrix = glm::lookAt(cameraPos, copter.position, glm::vec3(0, 1, 0)); break; default: cameraPos = glm::vec3(0, -8, 35); cameraPos = copter.position - glm::rotate(cameraPos, spinY, glm::vec3(0, 1, 0)); ViewMatrix = glm::lookAt(cameraPos, copter.position, glm::vec3(0, 1, 0)); } glUseProgram(cubeShader.handle()); //All of our geometry will have the same projection matrix. //we only need to set it once, since we are using the same shader. GLuint matLocation = glGetUniformLocation(cubeShader.handle(), "ProjectionMatrix"); glUniformMatrix4fv(matLocation, 1, GL_FALSE, &ProjectionMatrix[0][0]); cubeOne.ModelViewMatrix = glm::translate(ViewMatrix, glm::vec3(0, 20, 0)); glUniformMatrix4fv(glGetUniformLocation(cubeShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &cubeOne.ModelViewMatrix[0][0]); //cubeOne.render(); worldCube.ModelViewMatrix = glm::translate(ViewMatrix, glm::vec3(0, 0, 0)); glUniformMatrix4fv(glGetUniformLocation(cubeShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &worldCube.ModelViewMatrix[0][0]); //worldCube.render(); glUseProgram(0); glUseProgram(myShader.handle()); // use the shader glUniform1f(glGetUniformLocation(myShader.handle(), "displacement"), amount); glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ProjectionMatrix"), 1, GL_FALSE, &ProjectionMatrix[0][0]); //viewMatrix = glm::lookAt(glm::vec3(0, 0, -100), glm::vec3(30, 0, 0), //glm::vec3(0, 1, 0)); glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ViewMatrix"), 1, GL_FALSE, &ViewMatrix[0][0]); //Changing from daylight to night setting //Lighting Properties passed to the shader if (dayNight == 0) { Light_Ambient_And_Diffuse = glm::vec4{ 0.8, 0.8, 0.6, 1.0 }; Light_Specular = glm::vec4{ 0.8, 0.8, 0.8, 1.0 }; } else { Light_Ambient_And_Diffuse = glm::vec4{ 0.2, 0.2, 0.2, 1.0 }; Light_Specular = glm::vec4{ 0.2, 0.2, 0.2, 1.0 }; } glUniform4fv(glGetUniformLocation(myShader.handle(), "LightPos"), 1, &LightPos[0]); glUniform4fv(glGetUniformLocation(myShader.handle(), "light_ambient"), 1, &Light_Ambient_And_Diffuse[0]); glUniform4fv(glGetUniformLocation(myShader.handle(), "light_diffuse"), 1, &Light_Ambient_And_Diffuse[0]); glUniform4fv(glGetUniformLocation(myShader.handle(), "light_specular"), 1, &Light_Specular[0]); //DRAW THE MODEL copter.ModelViewMatrix = glm::translate(ViewMatrix, copter.position); copter.ModelViewMatrix = glm::rotate(copter.ModelViewMatrix, spinY, glm::vec3(0, 1, 0)); //rotate object about y axis copter.ModelViewMatrix = glm::rotate(copter.ModelViewMatrix, tiltX, glm::vec3(0, 0, 1)); //tilts the cube around x copter.ModelViewMatrix = glm::rotate(copter.ModelViewMatrix, tiltZ, glm::vec3(1, 0, 0)); //tilts the cube around z //Pass the uniform for the modelview matrix glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &copter.ModelViewMatrix[0][0]); glm::mat4 normalMatrix; glm::mat4 NormalMatrix = ModelViewMatrix * normalMatrix; glUniformMatrix3fv(glGetUniformLocation(myShader.handle(), "NormalMatrix"), 1, GL_FALSE, &normalMatrix[0][0]); copter.render(); //model.drawElementsUsingVBO(&myShader); //prop.ModelViewMatrix = glm::translate(prop.ModelViewMatrix, glm::vec3(0, 0, 0)); prop.ModelViewMatrix = copter.ModelViewMatrix; prop.render(propSpin); //Drawing the world world.ModelViewMatrix = glm::translate(ViewMatrix, glm::vec3(0, 1790, 0)); glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &world.ModelViewMatrix[0][0]); world.render(); ground.ModelViewMatrix = glm::translate(ViewMatrix, glm::vec3(0, -55, 0)); glUniformMatrix4fv(glGetUniformLocation(myShader.handle(), "ModelViewMatrix"), 1, GL_FALSE, &ground.ModelViewMatrix[0][0]); ground.render(); //for (int i = 0; i < houses.size(); i++) //{ // houses[i].render(ViewMatrix); //} //for (int i = 0; i < trees.size(); i++) //{ // trees[i].render(ViewMatrix); //} houseOne.render(ViewMatrix); houseTwo.render(ViewMatrix); houseThree.render(ViewMatrix); houseFour.render(ViewMatrix); houseFive.render(ViewMatrix); houseSix.render(ViewMatrix); treeOne.render(ViewMatrix); treeTwo.render(ViewMatrix); treeThree.render(ViewMatrix); treeFour.render(ViewMatrix); treeFive.render(ViewMatrix); treeSix.render(ViewMatrix); treeSeven.render(ViewMatrix); treeEight.render(ViewMatrix); treeNine.render(ViewMatrix); treeTen.render(ViewMatrix); leafOne.render(ViewMatrix); leafTwo.render(ViewMatrix); leafThree.render(ViewMatrix); leafFour.render(ViewMatrix); glUseProgram(0); //turn off the current shader }
void init() { glClearColor(1.0,1.0,1.0,0.0); //sets the clear colour to yellow //glClear(GL_COLOR_BUFFER_BIT) in the display function//will clear the buffer to this colour. // Shaders if(!myShader.load("BasicView", "glslfiles/basicTransformations.vert", "glslfiles/basicTransformations.frag")) { cout << "failed to load shader" << endl; } if (!cubeShader.load("BasicView", "glslfiles/cubeShader.vert", "glslfiles/cubeShader.frag")) { cout << "failed to load shader" << endl; } cubeOne.setDim(15); cubeOne.constructGeometry(&cubeShader); worldCube.setDim(1000); worldCube.constructGeometry(&cubeShader); glEnable(GL_TEXTURE_2D); copter.loadModel(myShader); prop.loadModel(myShader); world.loadModel(myShader); ground.loadModel(myShader); houseOne.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(50, 44, 50), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); houseTwo.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(-1250, 44, 1000), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); houseThree.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(-500, 44, -500), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); houseFour.loadModel(myShader, "TestModels/pyramidhouse2.obj", glm::vec3(1200, 44, 1200), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); houseFive.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(50, 44, -1150), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); houseSix.loadModel(myShader, "TestModels/dododododhouse2.obj", glm::vec3(-900, 44, -500), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 0); treeOne.loadModel(myShader, "TestModels/tree.obj", glm::vec3(250, 20, 250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeTwo.loadModel(myShader, "TestModels/tree.obj", glm::vec3(350, 20, 250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeThree.loadModel(myShader, "TestModels/tree.obj", glm::vec3(300, 20, 250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeFour.loadModel(myShader, "TestModels/tree.obj", glm::vec3(0, 20, 750), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeFive.loadModel(myShader, "TestModels/tree.obj", glm::vec3(200, 20, 180), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeOne.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-900, 20, 580), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeTwo.loadModel(myShader, "TestModels/tree.obj", glm::vec3(1040, 20, 1050), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeThree.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-1260, 20, -250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeFour.loadModel(myShader, "TestModels/tree.obj", glm::vec3(1270, 20, 250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); treeFive.loadModel(myShader, "TestModels/tree.obj", glm::vec3(-230, 20, 250), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); leafOne.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 580), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); leafTwo.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(170, -10, 530), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); leafThree.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 550), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); leafFour.loadModel(myShader, "TestModels/leaf.obj", glm::vec3(150, -10, 510), glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, glm::vec4{ 0.8, 0.8, 0.8, 1.0 }, 50); houses.push_back(houseOne); houses.push_back(houseTwo); houses.push_back(houseThree); houses.push_back(houseFour); houses.push_back(houseFive); houses.push_back(houseSix); trees.push_back(treeOne); trees.push_back(treeTwo); trees.push_back(treeThree); trees.push_back(treeFour); trees.push_back(treeFive); trees.push_back(treeSix); trees.push_back(treeSeven); trees.push_back(treeEight); trees.push_back(treeNine); trees.push_back(treeTen); leafs.push_back(leafOne); leafs.push_back(leafTwo); leafs.push_back(leafThree); leafs.push_back(leafFour); glEnable(GL_DEPTH_TEST); }
void Ant::createMoveDistribution(Ground & ground) { int range = 10; int dirrl = abs(x - nest_x) > range ? x - nest_x : 0; int dirud = abs(y - nest_y) > range ? y - nest_y : 0; Direction act_direction = getDirectionFromDifferenceSigns(dirrl, dirud); // if (act_direction == last_direction && move_distribution != nullptr) // { // return; // } if (move_distribution != nullptr) { delete move_distribution; } last_direction = act_direction; double zones = 4; double left_max = ground.getLeftDistanceFromNestToBorder(id); double up_max = ground.getUpDistanceFromNestToBorder(id); double right_max = ground.getRightDistanceFromNestToBorder(id); double down_max = ground.getDownDistanceFromNestToBorder(id); int lr = abs(nest_x - x); int ud = abs(nest_y - y); int iprobl = lr && left_max ? zones - lr / (left_max / zones) : 1; int iprobr = lr && right_max ? zones - lr / (right_max / zones) : 1; int iprobu = ud && up_max ? zones - ud / (up_max / zones) : 1; int iprobd = ud && down_max ? zones - ud / (down_max / zones) : 1; double a = 0.25; double b = 0.75; double probl = iprobl ? iprobl * a + b : 1; double probr = iprobr ? iprobr * a + b : 1; double probu = iprobu ? iprobu * a + b : 1; double probd = iprobd ? iprobd * a + b : 1; switch (act_direction) { case Direction::UL: move_distribution = new std::discrete_distribution<> ({std::min(probl, probu), probu, probu, probl, 1, probl, 1, 1}); break; case Direction::UR: move_distribution = new std::discrete_distribution<> ({probu, probu, std::min(probr, probu), 1, probr, 1, 1, probr}); break; case Direction::U: move_distribution = new std::discrete_distribution<> ({probu, probu, probu, 1, 1, 1, 1, 1}); break; case Direction::DL: move_distribution = new std::discrete_distribution<> ({probl, 1, 1, probl, 1, std::min(probd, probl), probd, probd}); break; case Direction::DR: move_distribution = new std::discrete_distribution<> ({1, 1, probr, 1, probr, probd, probd, std::min(probd, probr)}); break; case Direction::D: move_distribution = new std::discrete_distribution<> ({1, 1, 1, 1, 1, probd, probd, probd}); break; case Direction::L: move_distribution = new std::discrete_distribution<> ({probl, 1, 1, probl, 1, probl, 1, 1}); break; case Direction::R: move_distribution = new std::discrete_distribution<> ({1, 1, probr, 1, probr, 1, 1, probr}); break; case Direction::NO_DIRECTION: move_distribution = new std::discrete_distribution<> ({1, 1, 1, 1, 1, 1, 1, 1}); break; } }
int main(int argc, char **argv) { static_assert(std::is_pod<FVector3>::value, "FVector must be a POD!"); static_assert(std::is_pod<Oscillator>::value, "Oscillator must be a POD!"); // initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow("Fountain"); // textures std::unique_ptr<Texture> pebbleTexture(new Texture); std::unique_ptr<Texture> basinTexture(new Texture); std::unique_ptr<Texture> groundTexture(new Texture); std::unique_ptr<Texture[]> skyTextures(new Texture[SKY_BOX_FACES]); pebbleTexture->load("resource/pebbles.bmp"); basinTexture->load("resource/wall.bmp"); groundTexture->load("resource/grass.bmp"); skyTextures[SKY_FRONT].load("resource/skybox/front.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_RIGHT].load("resource/skybox/right.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_LEFT].load("resource/skybox/left.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_BACK].load("resource/skybox/back.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_UP].load("resource/skybox/up.bmp", GL_CLAMP_TO_EDGE); skyTextures[SKY_DOWN].load("resource/skybox/down.bmp", GL_CLAMP_TO_EDGE); // initialize the scene skybox.initialize(-SKY_BOX_SIZE, SKY_BOX_SIZE, -SKY_BOX_SIZE, SKY_BOX_SIZE, -SKY_BOX_SIZE, SKY_BOX_SIZE, std::move(skyTextures)); pool.initialize(OSCILLATORS_NUM_X, OSCILLATORS_NUM_Z, POOL_HEIGHT, OSCILLATOR_DISTANCE, OSCILLATOR_WEIGHT, OSCILLATOR_DAMPING, OSCILLATOR_SPLASH, POOL_TEX_REPEAT_X, POOL_TEX_REPEAT_Z, std::move(pebbleTexture)); fountain.initialize(initializers[0]); basin.initialize(BASIN_BORDER_HEIGHT + POOL_HEIGHT, BASIN_BORDER_WIDTH, BASIN_INNER_X, BASIN_INNER_Z, std::move(basinTexture)); ground.initialize(-GROUND_SIZE, GROUND_SIZE, -GROUND_SIZE, GROUND_SIZE, std::move(groundTexture), GROUND_TEX_REPEAT); // place the fountain in the center of the pool fountain.center.set(BASIN_INNER_X / 2.0f, POOL_HEIGHT, BASIN_INNER_Z / 2.0f); // initialize camera: FVector3 cposition, crotation; cposition.set(CAMERA_POSITION[0], CAMERA_POSITION[1], CAMERA_POSITION[2]); camera.move(cposition); crotation.set(CAMERA_ROTATION[0], CAMERA_ROTATION[1], CAMERA_ROTATION[2]); camera.rotate(crotation); // enable vertex array glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); // solid rendering glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_DEPTH_TEST); // lighting glLightfv(GL_LIGHT1, GL_AMBIENT, LIGHT_AMBIENT_1); glLightfv(GL_LIGHT1, GL_DIFFUSE, LIGHT_DIFFUSE_1); glLightfv(GL_LIGHT1, GL_POSITION, LIGHT_POSITION_1); glEnable(GL_LIGHT1); glLightfv(GL_LIGHT2, GL_AMBIENT, LIGHT_AMBIENT_2); glLightfv(GL_LIGHT2, GL_DIFFUSE, LIGHT_DIFFUSE_2); glLightfv(GL_LIGHT2, GL_POSITION, LIGHT_POSITION_2); glEnable(GL_LIGHT2); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); // settings glClearColor(0.0, 0.0, 0.0, 0.0); glFrontFace(GL_CCW); // orientation should be the front face glShadeModel(GL_SMOOTH); // blending glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // seed srand((unsigned)time(NULL)); printf("1 - 8:\tChange the shape of the fountain\n"); printf("f:\tToggle fullscreen\n"); printf("c:\tSwitch between mouse mode / keyboard mode\n"); printf("----------- Keyboard Mode -----------------\n"); printf("up, down:\tMove camera forward / backword\n"); printf("left, right:\tTurn camera right / left\n"); printf("r, v:\tTurn camera up / down\n"); printf("w, s:\tMove camera up / down\n"); printf("a, d:\tMove camera left / right\n"); printf("----------- Mouse Mode -----------------\n"); printf("Mouse move:\tRotate camera\n"); printf("Mouse scroll:\tMove forward / backward\n"); printf("ESC:\tExit\n"); // register callbacks glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyDown); glutPassiveMotionFunc(mouseMove); glutSpecialFunc(spKeyDown); glutMouseFunc(mouseButton); glutIdleFunc(idle); // hide cursor glutSetCursor(GLUT_CURSOR_NONE); // start glutMainLoop(); return 0; }
void Ant::followSmell(Ground& ground) { Direction dir = ground.followSmell(x, y, id); goToDirectionNoCheck(dir); }