Esempio n. 1
0
  const float& _TimeManager::getTurnPercent()
  {
    if( m_turnCompletion < 0 )
    {
      m_turnCompletion += 1;
      setTurn(m_turn - 1);
    } else if( m_turnCompletion >= 1 )
    {
      m_turnCompletion -= 1;
      setTurn(m_turn + 1);
    }

    return m_turnCompletion;

  } // _TimeManager::getTurnPercent()
Esempio n. 2
0
  void _TimeManager::setTurnPercent( const float& perc )
  {
    m_turnCompletion = perc;
    if( m_turnCompletion < 0 )
    {
      m_turnCompletion += 1;
      setTurn(m_turn - 1);
    } else if( m_turnCompletion >= 1 )
    {
      m_turnCompletion -= 1;
      setTurn(m_turn + 1);
    }


  } // _TimeManager::setTurnPercent()
Esempio n. 3
0
    const int& _TimeManager::prevTurn()
  {
    pause();
    setTurn(m_turn - 1);
    return getTurn();

  } // _TimeManager::prevTurn()
Esempio n. 4
0
  const int& _TimeManager::nextTurn()
  {
    pause();
    setTurn(m_turn + 1);
    return getTurn();

  } // _TimeManager::nextTurn()
Esempio n. 5
0
void setControl()
{
    while (run) {
      setSpeed(speed);
      setTurn(turn);
    }
}
Esempio n. 6
0
  void _TimeManager::abloop_on(const int& a, const int&b)
  {
	  loop_on = true;
	  loop_start = a;
	  loop_end = b;
	  setTurn(a);
	  play();
  }
Esempio n. 7
0
void NavigationControl::LineCallback(const Robosub::Line msg) {
	if(LINEMODE == OFF)
		return;

    OnLine = moveToLine(msg.x, msg.y);
    //Once it's on top of the line, rotate
    if (!OnLine){
        return; //keep rotating
    }

    int target_rot = sanitize(msg.rotation);
    if(!target_rot){
	 start_rot = 0;
         Rotating = 0;
	 setTurn(0);
	 return; //Stoppped by Higher Level
    }
    if(!Rotating){
        start_rot = target_rot;
    }

    float per_rot = (target_rot/180);//start_rot);


    //This needs to be implemented better (any ideas?)
    //int direction = 1; //always rotate right?
    int direction = target_rot>0 ? 1 : -1; //-1 Rotate left


    int rate = 0;
    int range=40;
    int minR = 50;

    if(abs(per_rot)<MAX_THRESHOLD ){
        if(abs(per_rot)>.01)
            rate = -60*direction;
        else
            rate = 0;
    } else {
        rate = (range*per_rot+minR)*direction;
    }

    setTurn(rate);

}
Esempio n. 8
0
void Options::setChanges()
{
    if(ui->playerORadio->isChecked())
        turn="O";
    else //if palyerXRadio is checked
        turn="X";

    if(ui->p2pRadio->isChecked())
        mode="P2P";
    else if (ui->p2cRadio->isChecked())
        mode="P2C";
    else //if c2c radio is checked
        mode="C2C";

    setMode(mode);
    setTurn(turn);
}
Esempio n. 9
0
void Game::nextTurn()
{
	setTurn(turn + 1);
}
Esempio n. 10
0
  void _TimeManager::timerUpdate()
  {
    // m_time.restart() returns the number of milliseconds
    // since it was last called.

    float secElapsed = (float)m_time.restart()/1000.0f;
	m_dt = secElapsed;
    m_turnCompletion += getSpeed() * secElapsed;

    if( m_turn < 0 )
    {
      setTurn(0);
    }

    if( m_turnCompletion > 1 )
    {
      size_t skip = floor( m_turnCompletion );
      setTurn(m_turn + skip);
      m_turnCompletion -= skip;

      if(loop_on && m_turn >= loop_end)
      {
        setTurn(loop_start);
      }

      if( (unsigned int)m_turn >= m_maxTurns )
      {
        setTurn(m_maxTurns - 1);
      }

      if( m_turn >= m_numTurns-1 && !m_breakout )
      {
        pause();

        setTurn(m_numTurns-1);
        // Very close to the next turn, but not quite
        m_turnCompletion = 0.9999f;

        if( !OptionsMan->getString( "Game Mode" ).compare( "Arena" ) )
        {
          if( !GUI->loadInProgress() )
          {
            m_breakout = true;
            GUI->requestGamelog();
          }
        } else if( OptionsMan->getNumber( "Continuous Play" ) )
        {
          GUI->playNext();
        }

      }
      else
      {
        if( m_turn >= m_numTurns-1 )
        {
          m_breakout = false;
          setTurn(m_numTurns - 1);
          m_turnCompletion = 0.01f;
        }
      }

    }
    else if( m_turnCompletion < -1 )
    {
      setTurn(m_turn + ceil( m_turnCompletion ));
      m_turnCompletion -= ceil( m_turnCompletion );

      if(loop_on && m_turn <= loop_start)
      {
        setTurn(loop_end);
      }

      if( m_turn <= 0 )
      {
        setTurn(0);
        m_turnCompletion = 0;
        pause();
      }

    }

    if( m_turn >= m_numTurns )
    {
      setTurn(m_numTurns - 1);
      m_turnCompletion = 0.9999f;
    }

    updateChildren();

  } // _TimeManager::timerUpdate()
Esempio n. 11
0
// Redraw the theme.
void ScoreSprite::changeTheme()
{
  // The main display is handled by the parent
  PixmapSprite::changeTheme();

  // Retrieve our size
  double width  = this->boundingRect().width();
  double height = this->boundingRect().height();

  // Retrieve theme data
  KConfigGroup config = thememanager()->config(id());
  QPointF posWon0     = config.readEntry("posWon0", QPointF(1.0,1.0));
  QPointF posWon1     = config.readEntry("posWon1", QPointF(1.0,1.0));
  QPointF posDraw0    = config.readEntry("posDraw0", QPointF(1.0,1.0));
  QPointF posDraw1    = config.readEntry("posDraw1", QPointF(1.0,1.0));
  QPointF posLoss0    = config.readEntry("posLoss0", QPointF(1.0,1.0));
  QPointF posLoss1    = config.readEntry("posLoss1", QPointF(1.0,1.0));
  QPointF posBreak0   = config.readEntry("posBreak0", QPointF(1.0,1.0));
  QPointF posBreak1   = config.readEntry("posBreak1", QPointF(1.0,1.0));
  QPointF posName0    = config.readEntry("posName0", QPointF(1.0,1.0));
  QPointF posName1    = config.readEntry("posName1", QPointF(1.0,1.0));
  QPointF posAI       = config.readEntry("posAI", QPointF(1.0,1.0));

  // Calculate proper font size
  double fontHeight = config.readEntry("fontHeight", 1.0);
  fontHeight *= height;
  double fontWidth = config.readEntry("fontWidth", 1.0);
  fontWidth *= width;
  
  // Retrieve font color
  QColor fontColor[2];
  fontColor[0] = config.readEntry("fontColorPlayer0", QColor(Qt::white));
  fontColor[1] = config.readEntry("fontColorPlayer1", QColor(Qt::white));

  // Set position of sub sprites
  mWon[0]->setPos(posWon0.x()*width, posWon0.y()*height);
  mWon[1]->setPos(posWon1.x()*width, posWon1.y()*height);
  mDraw[0]->setPos(posDraw0.x()*width, posDraw0.y()*height);
  mDraw[1]->setPos(posDraw1.x()*width, posDraw1.y()*height);
  mLoss[0]->setPos(posLoss0.x()*width, posLoss0.y()*height);
  mLoss[1]->setPos(posLoss1.x()*width, posLoss1.y()*height);
  mBreak[0]->setPos(posBreak0.x()*width, posBreak0.y()*height);
  mBreak[1]->setPos(posBreak1.x()*width, posBreak1.y()*height);
  mName[0]->setPos(posName0.x()*width, posName0.y()*height);
  mName[1]->setPos(posName1.x()*width, posName1.y()*height);


  // Create and set current font
  QFont font;
  font.setPixelSize(int(fontHeight));

  // Set font and color for all text items
  for (int i=0; i<2; i++)
  {
    mWon[i]->setFont(font);   
    mDraw[i]->setFont(font); 
    mLoss[i]->setFont(font);
    mBreak[i]->setFont(font);
    mName[i]->setFont(font);
    
    mWon[i]->setDefaultTextColor(fontColor[i]);   
    mDraw[i]->setDefaultTextColor(fontColor[i]);
    mLoss[i]->setDefaultTextColor(fontColor[i]);
    mBreak[i]->setDefaultTextColor(fontColor[i]);
    mName[i]->setDefaultTextColor(fontColor[i]);

    mWon[i]->setTextWidth(fontWidth);   
    mDraw[i]->setTextWidth(fontWidth);
    mLoss[i]->setTextWidth(fontWidth);
    mBreak[i]->setTextWidth(fontWidth);
    mName[i]->setTextWidth(fontWidth);

    // Restore the frame of the input device sprite
    if (mInputFrame[i]>=0) mInput[i]->setFrame(mInputFrame[i]);
  }

  // Update next player
  if (mTurn>=0) setTurn(mTurn);
}