Example #1
0
void SmartString::setWidth(int w) {
    m_width = w;
    if(abs(m_width) < getMaxWidth() * 0.2) {
        setColors(E::P.C400);
    } else if(abs(m_width) < getMaxWidth() * 0.4) {
        setColors(E::P.C300);
    } else if(abs(m_width) < getMaxWidth() * 0.6) {
        setColors(E::P.C200);
    } else if(abs(m_width) < getMaxWidth() * 0.7) {
        setColors(E::P.C100);
    } else {
        setColors(E::P.C50);
    }
    m_speed = 3 * getMaxWidth() / (abs(m_width) + 128);
    if(m_width > getMaxWidth()) {
        m_width = getMaxWidth();
    }
    if(m_width < - getMaxWidth()) {
        m_width = - getMaxWidth();
    }
    if(m_width < 0) {
        m_width = -m_width;
        this->setPositionX(m_startingPoint.x-m_width);
    }
    m_middle->setScaleX(m_width / this->getScale());
    _updatePosition();
}
Example #2
0
//Update method
void EditorMouse::Update(float)
{
	//Get input and physics manager
	IND_Input* input = SingletonIndieLib::Instance()->Input;
	
	//Update mouse position
	float newx = static_cast<float>(input->GetMouseX());
	float newy = static_cast<float>(input->GetMouseY());
	_updatePosition(newx,newy);
	
	//Left-Dragging tracking
	if(input->OnMouseButtonPress(IND_MBUTTON_LEFT) && !mRightDragging)
	{	
		mDragging = true;
	}
	else if(input->OnMouseButtonRelease(IND_MBUTTON_LEFT))
	{
		mDragging = false;
	}
	//Right-Dragging tracking
	if(input->OnMouseButtonPress(IND_MBUTTON_RIGHT) && !mDragging)
	{	
		mRightDragging = true;
	}
	else if(input->OnMouseButtonRelease(IND_MBUTTON_RIGHT))
	{
		mRightDragging = false;
	}

	//Move and define bodies (dragging commands) commands
	//Move tile command (dragging and left-button)
	mEditor->MoveTileCommand(input->IsMouseButtonPressed(IND_MBUTTON_LEFT) && mDragging);
	//Define body command (dragging and right-button)
	mEditor->DefineBodyCommand(input->IsMouseButtonPressed(IND_MBUTTON_RIGHT) && mRightDragging);

	//Zoom commands
	if(input->OnMouseButtonPress(IND_MBUTTON_WHEELUP ))
	{
		mEditor->ZoomInCommand();
	}
	else if(input->OnMouseButtonPress(IND_MBUTTON_WHEELDOWN))
	{
		mEditor->ZoomOutCommand();
	}
	
	//Other commands

	//Mix Keyboard and mouse (change add-to body)
	if((input->IsKeyPressed(IND_LCTRL) 
	   ||
	   input->IsKeyPressed(IND_RCTRL))
	   &&
	   input->OnMouseButtonPress(IND_MBUTTON_LEFT))
	{
		mEditor->ChangeBodyToAddShapesTo();
	}
}
Example #3
0
void TimeOfDay::unpackUpdate( NetConnection *conn, BitStream *stream )
{
   Parent::unpackUpdate( conn, stream );

   if ( stream->readFlag() ) // OrbitMask
   {
      stream->read( &mStartTimeOfDay );
      stream->read( &mDayLen );
      stream->read( &mTimeOfDay );
      stream->read( &mAxisTilt );
      stream->read( &mAzimuthOverride );

      stream->read( &mDayScale );
      stream->read( &mNightScale );

      mPlay = stream->readFlag();

      _updatePosition();
   }
}
Example #4
0
void TimeOfDay::advanceTime( F32 timeDelta )
{
   if ( !mPlay )
      return;
   
   F32 elevation = mRadToDeg( mElevation );
   bool daytime = false;

   if ( elevation > 350.0f || ( 0.0f <= elevation && elevation < 190.0f ) )
   {
      timeDelta *= mDayScale;
      daytime = true;
   }
   else
   {
      timeDelta *= mNightScale;
      daytime = false;
   }

   //Con::printf( "elevation ( %f ), ( %s )", elevation, ( daytime ) ? "day" : "night" );

   // do time updates   
   mTimeOfDay += timeDelta / mDayLen;

   // It could be possible for more than a full day to 
   // pass in a single advance time, so I put this inside a loop
   // but timeEvents will not actually be called for the
   // skipped day.
   while ( mTimeOfDay > 1.0f )
      mTimeOfDay -= 1.0f;

   _updatePosition();

   if ( isServerObject() )
      _updateTimeEvents();
}
Example #5
0
void TimeOfDay::inspectPostApply()
{
   _updatePosition();
   setMaskBits( OrbitMask );
}
Example #6
0
void Hero::update()
{
    _updatePosition();
}
Example #7
0
void SmartString::setPositionY(float y) {
    Sprite::setPositionY(y);
    _updatePosition();
}
Example #8
0
void SmartString::setPosition(const Vec2& pos) {
    Sprite::setPosition(Vec2(pos.x, pos.y));
    _updatePosition();
}
Example #9
0
void Mecha::update()
{
    _updatePosition();
    _updateAim();
    _updateAttack();
}