Example #1
0
      //! On message GpsFix
      //! @param[in] msg pointer to GpsFix message
      void
      onGpsFix(const IMC::GpsFix* msg)
      {
        float dist;

        switch (m_pstate)
        {
          case ST_GET_FIX:
          case ST_SKEEP:
            if (!(msg->validity & IMC::GpsFix::GFV_VALID_POS))
              break;

            double lat;
            double lon;
            Coordinates::toWGS84(m_state, lat, lon);

            dist = Coordinates::WGS84::distance(lat, lon, 0.0,
                                                msg->lat, msg->lon, 0.0);

            if (msg->satellites >= m_args->min_sats &&
                dist < m_args->min_distance)
            {
              goDown();
              m_pstate = ST_GO_DOWN;
            }
            break;
          default:
            break;
        }
      }
Example #2
0
      //! On message EstimatedState
      //! @param[in] msg pointer to EstimatedState message
      void
      onEstimatedState(const IMC::EstimatedState* msg)
      {
        m_state = *msg;

        switch (m_pstate)
        {
          case ST_GO_UP:
          case ST_GO_DOWN:
            m_elevate->update(msg);
            break;
          case ST_SKEEP:
            if (isSKeepTooFar(msg))
            {
              startStationKeeping();
              m_task->inf(DTR("relocated station keeping"));
            }

            m_skeep->update(msg);
            if (m_dur_timer.overflow())
            {
              goDown();
              m_pstate = ST_GO_DOWN;
            }
            break;
          default:
            break;
        }
      }
Example #3
0
int CubesterTTP::getAction(Ogre::Vector3 playerPos)
{
    int caseNum = (actionIndex/pathLength) % 2;
    if(caseNum == 0 ) // 0 to pathLength go right
        return goDown();
    else
        reload();
}
Example #4
0
bool Board::handleInput()
{
    //If a key was pressed
    if( event.type == SDL_KEYDOWN )
    {
        //Adjust the velocity
        switch( event.key.keysym.sym )
        {
            case SDLK_UP:return rotate();
            case SDLK_LEFT:return moveLeft();
            case SDLK_RIGHT:return moveRight();
			case SDLK_DOWN: goDown(); return true;
			case SDLK_SPACE:while(goDown()); return true;
            default:;
        }
    }
    return false;

}
Example #5
0
int AbstractCubester::move(int dir)
{
    if(dir == 0 ) // 0 to pathLength go right
        return goUp();
    else if(dir == 1)
        return goRight();
    else if(dir == 2)
        return goDown();
    else if(dir == 3)
        return goLeft();
}
Example #6
0
void Mouse::move()
{
	if (icon == 0)
		goRight();
	else if (icon == 1)
		goLeft();
	else if (icon == 2)
		goUp();
	else
		goDown();
}
Example #7
0
int CubesterCCBLSquare::getAction(Ogre::Vector3 playerPos)
{
    int caseNum = (actionIndex/pathLength) % 4;
    if(caseNum == 0 ) // 0 to pathLength go right
        return goRight();
    else if(caseNum == 1)
        return goUp();
    else if(caseNum == 2)
        return goLeft();
    else if(caseNum == 3)
        return goDown();
}
Example #8
0
void Npc::updateCurrent(CommandQueue &command_queue, const sf::Time dt)
{
	if (isActive())
	{
		updateAnimation(dt);
		action_queue.update(dt);

		if (getCurrentDirection() == Direction::Left) goLeft(dt);
		else if (getCurrentDirection() == Direction::Right) goRight(dt);
		else if (getCurrentDirection() == Direction::Up) goUp(dt);
		else if (getCurrentDirection() == Direction::Down) goDown(dt);
	}
}
Example #9
0
void checkRelation(Task * task)
{
	if (task->cur->rel == NULL)
	{
		task->cur = NULL;
		return;
	}

	switch (task->cur->rel->relType)
	{
		case TREL_SCRIPT:
			task->cur = task->cur->rel->next;
			goDown(task);
			break;
		case TREL_OR:
			debug("IN OR Getted %d\n", task->curRet);
			if (task->curRet != 0)
			{
				task->cur = task->cur->rel->next;
				goDown(task);
			}
			else
				goUp(task);
			break;
		case TREL_AND:
			debug("IN AND Getted %d\n", task->curRet);
			if (task->curRet == 0)
			{
				task->cur = task->cur->rel->next;
				goDown(task);
			}
			else
				goUp(task);
			break;
		case TREL_END:
			goUp(task);
			break;
	}
}
Example #10
0
int Field::goDown(Point ind, bool scoreit)
{

	Point next_ind = ind;
	next_ind.y+=1;
	int sum=1;

	if (At(next_ind) && At(next_ind)->IsID(At(ind))) sum+=goDown(next_ind,scoreit);
	if (scoreit) 
	{
		StartAnimation(ind);
	}
	return sum; 
}
Example #11
0
void goDown(Task * task)
{
	if (task == NULL)
		return;

	switch (task->cur->cmdType)
	{
		case TCMD_SCRIPT:
		case TCMD_LIST:
			task->cur = task->cur->child;
			goDown(task);
			break;
	}
}
Example #12
0
void Enemy::patrol()
{

	std::discrete_distribution<int> dir_distribution({ 60, 10, 10, 10, 10 });
	std::uniform_int_distribution<int> distance_distribution(50, 100);
	std::uniform_real_distribution<float> wait_time_distribution(1.f, 3.f);
	Direction dir = static_cast<Direction>(dir_distribution(mt));
	int distance = distance_distribution(mt);
	stop_time = sf::seconds(wait_time_distribution(mt));
	

	//Action selection
	Action patrol;
	patrol.thread_id = 1;
	patrol.action = get_action([this, dir, distance](sf::Time dt)
	{
		if (dir == Direction::Left) { moveLeft(distance); }
		else if (dir == Direction::Right) { moveRight(distance); }
		else if (dir == Direction::Up) { moveUp(distance); }
		else if (dir == Direction::Down) { moveDown(distance); }
		//else if (dir == Direction::None) { std::cout << "Stop time" << stop_time.asSeconds() << std::endl; wait(stop_time); }
		

		return false;
	});
	//When we have 2 actions we stop action addition
	unsigned int max_actions = 2;
	if (action_tree.threadSize(patrol.thread_id) < max_actions)
	{
		pushAction(patrol);
	}


	//Action updating, each frame
	Action patrol_update;
	patrol_update.thread_id = 0;
	patrol_update.action = get_action([this](sf::Time dt)
	{
		if (getCurrentDirection() == Direction::Left) { goLeft(dt); }
		else if (getCurrentDirection() == Direction::Right) { goRight(dt); }
		else if (getCurrentDirection() == Direction::Up) { goUp(dt); }
		else if (getCurrentDirection() == Direction::Down) { goDown(dt); }

		return false;
	});
	pushAction(patrol_update);

	
}
Example #13
0
void MainMenuController::handleEvents(sf::Event &event) {
    IController::handleEvents(event);
    if (event.type == sf::Event::KeyPressed) {
        ///EVENT FOR BUTTONS :
        if (event.key.code == sf::Keyboard::Return) {
            fireButton();
        }
        else if (event.key.code == sf::Keyboard::Up) {
            goUp();
        }
        else if (event.key.code == sf::Keyboard::Down) {
            goDown();
        }
    }
}
int main()
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;
    pos.X = 0;
    pos.Y = 0;
    SetConsoleCursorPosition(hConsole, pos);
    while(pos.X < cols){
        goDown(&pos, hConsole);
        if(pos.X == cols - 1) break;
        pos.X++;
        SetConsoleCursorPosition(hConsole, pos);

        goUp(&pos, hConsole);
        pos.X++;
        SetConsoleCursorPosition(hConsole, pos);
    }
    return EXIT_SUCCESS;
}
Example #15
0
/**
 * Test keys and try move, use borrowed controls.
 * @return a symbol when unit has moved or SYM_NONE
 */
char
Unit::driveBorrowed(const InputProvider *input, const KeyControl &buttons)
{
    if (canDrive()) {
        if (input->isPressed(buttons.getLeft())) {
            return goLeft();
        }
        if (input->isPressed(buttons.getRight())) {
            return goRight();
        }
        if (input->isPressed(buttons.getUp())) {
            return goUp();
        }
        if (input->isPressed(buttons.getDown())) {
            return goDown();
        }
    }
    return ControlSym::SYM_NONE;
}
Example #16
0
/**
 * Make move.
 * @return move symbol or SYM_NONE for bad move
 */
char
Unit::driveOrder(char move)
{
    if (canDrive()) {
        if (m_symbols.getLeft() == move) {
            return goLeft();
        }
        if (m_symbols.getRight() == move) {
            return goRight();
        }
        if (m_symbols.getUp() == move) {
            return goUp();
        }
        if (m_symbols.getDown() == move) {
            return goDown();
        }
    }
    return ControlSym::SYM_NONE;
}
Example #17
0
/*
 * This controls where the cursor moves to next.
 * Press w to go up
 * Press a to go left
 * Press s to go down
 * Press d to go right
 */
void control(unsigned char c, point * p, int (*board)[width]){
	if(c == 'w'){
		goUp(p, board);
	}
	if(c == 'a'){
		goLeft(p, board);	
	}
	if(c == 's'){
		goDown(p,board);		
	}

	if(c == 'd'){
		goRight(p,board);		
	}
	//9 corresponds to Tab
	if(c == 9){
		clearGrid(board, p);
	}
}
Example #18
0
void getNextJob(Task * task)
{
	if (task == NULL || task->cur == NULL)
		return;

	switch (task->cur->cmdType)
	{
		case TCMD_SCRIPT:
		case TCMD_LIST:
			goDown(task);
			break;
		case TCMD_PIPE:
		case TCMD_SIMPLE:
			if (!task->firstly)
				checkRelation(task);
			break;
	}

	if (task->firstly)
		task->firstly = 0;
}
Example #19
0
void RoboPult::Down()
  {
      if(askStena->isChecked () ){emit hasDownWall(); askStena->setChecked(false);switchButt();return;};
      if(askFree->isChecked () ){emit noDownWall(); askFree->setChecked(false);switchButt();return;};
  emit goDown();
  };
Example #20
0
void playBlock(void)
{
 unsigned char a=0;
 collisionDetect();
 if(collision > 0)
 {
  arrayOr();
  lcdWrite();
  gameOver();
 }
 else
 {
 goDown();
 arrayOr();
 collisionDetect();
 bottomReachDetect();
 if( (collision+bottom) == 0)
 {
 a = (PINC&0B00001111);
 if (a == 0B00001110) 
 {
  goLeft();
 }
 if (a == 0B00001101) 
 {
  goRight();
 }
 if (a == 0B00000111) 
 {
  blockTurn();
 }
  if (a== 0B00001011)
 {
  _delay_ms(50);
 }
 else
 {
  switch(level)
  {
  case 1:
  _delay_ms(500);
  break;
  
  case 2:
  _delay_ms(350);
  break;
  
  case 3:
  _delay_ms(250);
  break;
  
  case 4:
  _delay_ms(125);
  break;
  
  case 5:
  _delay_ms(75);
  break;
  }
 }
 }
 if (collision==0)
 {
  lcdWrite();
 }
 }
}