Beispiel #1
0
Game_Player::Game_Player():
	location(Main_Data::game_data.party_location),
	teleporting(false),
	vehicle_type(-1),
	vehicle_getting_on(false),
	vehicle_getting_off(false),
	new_map_id(0),
	new_x(0),
	new_y(0),
	last_pan_x(0),
	last_pan_y(0) {
	SetDirection(RPG::EventPage::Direction_down);
	SetMoveSpeed(4);
}
void FieldCharacter::UpdateDirection(Vector2 directionVector)
{
    directionVector = directionVector.Normalize();

    // We'll snap the player's direction vector according to
    // the nearest direction for which we have an animation.
    double angleToHorizontal = acos(directionVector.GetX());

    // acos() only returns values from 0 to pi,
    // so to get the full circle we need to check
    // whether we're in the bottom two quandrants,
    // and change the angle to account for this if so.
    if (directionVector.GetY() > 0)
    {
        angleToHorizontal = 2 * M_PI - angleToHorizontal;
    }

    if (angleToHorizontal <= M_PI / 8 || angleToHorizontal > M_PI * 15 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionSide);
        SetDirection(CharacterDirectionRight);
    }
    else if (angleToHorizontal > M_PI / 8 && angleToHorizontal <= M_PI * 3 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
        SetDirection(CharacterDirectionRight);
    }
    else if (angleToHorizontal > 3 * M_PI / 8 && angleToHorizontal <= M_PI * 5 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionUp);
    }
    else if (angleToHorizontal > 5 * M_PI / 8 && angleToHorizontal <= M_PI * 7 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 7 * M_PI / 8 && angleToHorizontal <= M_PI * 9 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionSide);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 9 * M_PI / 8 && angleToHorizontal <= M_PI * 11 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 11 * M_PI / 8 && angleToHorizontal <= M_PI * 13 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDown);
    }
    else if (angleToHorizontal > 13 * M_PI / 8 && angleToHorizontal <= M_PI * 15 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
        SetDirection(CharacterDirectionRight);
    }
}
Beispiel #3
0
void SceneCamera::Update(){

    if(inversed) {
    	SetUp(control[currentType]->GetUp() * -1);
    	//SetPosition(control[currentType]->GetPosition() * -1);
		//SetDirection(control[currentType]->GetDirection() *-1 );
    } else {
    	SetUp(control[currentType]->GetUp());
    	SetPosition(control[currentType]->GetPosition());
		SetDirection(control[currentType]->GetDirection());
    }

    
 //   cout << "[SCENECAMERA][Update] controltype " << (int)currentType << endl;
}
Beispiel #4
0
	void MoveCamera(int direction, float delta) {
		CPoint3D v;
		switch (direction){
		case BACK: delta = -delta;
		case FRONT:
			v = At - P0;
			v.Normalize();
			SetPosition(P0 + delta*v);
			SetDirection(At + delta*v); break;
		case LEFT: delta = -delta;
		case RIGHT:
			v = CrossProduct(At - P0, Up);
			v.Normalize();
			SetPosition(P0 + delta*v);
			SetDirection(At + delta*v); break;
		case DOWN: delta = -delta;
		case UP:
			v = Up;
			v.Normalize();
			SetPosition(P0 + delta*v);
			SetDirection(At + delta*v); break;
		}
		Update();
	}
Beispiel #5
0
void MyPositionController::OnCompassUpdate(location::CompassInfo const & info, ScreenBase const & screen)
{
  double const oldAzimut = GetDrawableAzimut();

  if ((IsInRouting() && m_mode == location::FollowAndRotate) ||
      m_lastGPSBearing.ElapsedSeconds() < kGpsBearingLifetimeSec)
    return;

  SetDirection(info.m_bearing);

  if (m_isPositionAssigned && !AlmostCurrentAzimut(oldAzimut) && m_mode == location::FollowAndRotate)
  {
    CreateAnim(GetDrawablePosition(), oldAzimut, screen);
    m_isDirtyViewport = true;
  }
}
void CCamera::Init(const XMVECTOR& position_in,
	const XMVECTOR& direction_in,
	const XMVECTOR& up_in,
	XMMATRIX* pMatView_in,
	XMMATRIX* pMatProj_in,
	XMMATRIX* pMatViewProj_in)
{
	pMatView = pMatView_in;
	pMatProj = pMatProj_in;
	pMatViewProj = pMatViewProj_in;
	SetPosition(position_in);
	SetDirection(direction_in);
	SetUp(up_in);
	directionOriginale = direction;
	orientationCamera = 0;   // 0,1,0   sinon  atan(y/x);
}
Beispiel #7
0
CCamera_Scene::CCamera_Scene(Ogre::Camera* pOgreCamera, const fVector3& fvPos, FLOAT fAddHeight, FLOAT fPitch, FLOAT fDistance, FLOAT fDirection)
    : CCamera(pOgreCamera)
{
    //-----------------------------------------------
    // 进行初始化设置
    SetLookAt(fvPos);
    SetAddHeight(fAddHeight);
    SetPitch(fPitch);
    SetApprochPitch( fPitch );
    SetDistance(fDistance);
    SetDirection(fDirection);

    m_status = NORMAL_STATUS;
    m_fOffset = 0.0f;
    Fairy::EffectManager::getSingleton().setEffectCameraShakeCallback(&s_EffectCameraShakeCallback);
}
Beispiel #8
0
bool RuntimeSpriteObject::ChangeProperty(unsigned int propertyNb, std::string newValue)
{
    if ( propertyNb == 0 ) { return SetCurrentAnimation(ToInt(newValue)); }
    else if ( propertyNb == 1 )
    {
        if ( currentAnimation >= GetAnimationsCount() ) return false;

        return animations[currentAnimation].Get().useMultipleDirections ? SetDirection(ToInt(newValue)) : SetAngle(ToFloat(newValue));
    }
    else if ( propertyNb == 2 ) { return SetSprite(ToInt(newValue)); }
    else if ( propertyNb == 3 ) { SetOpacity(ToFloat(newValue)); }
    else if ( propertyNb == 4 ) { SetBlendMode(ToInt(newValue)); }
    else if ( propertyNb == 5 ) {SetScaleX(ToFloat(newValue));}
    else if ( propertyNb == 6 ) {SetScaleY(ToFloat(newValue));}

    return true;
}
Beispiel #9
0
bool RuntimeSpriteObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
    if ( propertyNb == 0 ) { return SetCurrentAnimation(newValue.To<int>()); }
    else if ( propertyNb == 1 )
    {
        if ( currentAnimation >= GetAnimationsCount() ) return false;

        return animations[currentAnimation].Get().useMultipleDirections ? SetDirection(newValue.To<std::size_t>()) : SetAngle(newValue.To<float>());
    }
    else if ( propertyNb == 2 ) { return SetSprite(newValue.To<int>()); }
    else if ( propertyNb == 3 ) { SetOpacity(newValue.To<float>()); }
    else if ( propertyNb == 4 ) { SetBlendMode(newValue.To<int>()); }
    else if ( propertyNb == 5 ) {SetScaleX(newValue.To<float>());}
    else if ( propertyNb == 6 ) {SetScaleY(newValue.To<float>());}

    return true;
}
Beispiel #10
0
QuadPID::QuadPID(float kp, float ki, float kd, float *input, float *output, float *setpoint, MilliSec_t sample_period)
{
	// pointeurs, entrées, sorties consignes
	Input = input;
	Output = output;
	Setpoint = setpoint;

	// période de calcule par défaut 50Hz : 20ms
	DefaultSamplePeriod = SamplePeriod = sample_period;

	// mode automatique (par défaut)
	Mode = QUADPID_AUTOMATIC;

	// mise en place des paramètres
	SetTunings(kp, ki, kd);
	SetDirection(QUADPID_DIRECT);
	SetOutputLimits(0, 255);
}
Beispiel #11
0
void CJeep::HandleEvent( CEvent* pEvent )
{
	CPlayer* pPlayer = CPlayer::GetInstance();

	if(pEvent->GetEventID() == "Change_Position" && pEvent->GetParam() == this)
	{
		SetPosX(-200.0f);
		SetPosY(-200.0f);
	}

	if(pEvent->GetEventID() == "Spawn_Jeep" && pEvent->GetParam() == this)
	{
		SetPosX(pPlayer->GetPosX()+20);
		SetPosY(pPlayer->GetPosY());
		SetDirection(CJeepState::GetInstance()->GetDirectionX(), CJeepState::GetInstance()->GetDirectionY());
		SetRotation(CJeepState::GetInstance()->GetRotation());
	}
}
Beispiel #12
0
void MovingObjectModel::RecalculatePath()
{
	//Only do stuff if the path contains elements.
	if(m_Path != NULL && !m_Path->empty())
	{
		auto next = m_Path->at(0);

		Point tempDirection = next - GetPosition();
		float distance = tempDirection.GetLength();
		tempDirection = tempDirection.GetNormalizedPoint();

		Point oppositDirection = m_Direction.GetNegatedPoint();
		oppositDirection = oppositDirection.GetNormalizedPoint();

		//If direction got negated, we overshot our target or if we have reached our next goal
		if(tempDirection == &oppositDirection || distance < 0.01f)
		{
			m_Path->erase(m_Path->begin());

			if(m_Path->empty())
			{
				m_MovementSpeed = 0;
			}
			else
			{
				next = m_Path->at(0);
				auto pos = GetPosition();

				Point newDirection = next - pos;
				newDirection = newDirection.GetNormalizedPoint();

				if(m_Owner != NULL)
				{
					m_Owner->setLookAt2D(newDirection.X, newDirection.Y);
				}
				else
				{
					SetDirection(newDirection.X, newDirection.Y);
				}
			}

		}
	}
}
bool Player::CalculateDirection()
{
	float x, y, z;
	bool moved = false;

	x = 0;
	y = 0;//Box(DirectX::XMFLOAT3(35.0f, 0.0f, 0.0f), DirectX::XMFLOAT3(1.0f, 1.0f, 40.0f)))
	z = 0;
	//m_playerPrevPos = m_position;

	if (InputManager::GetInstance()->IsKeyPressed(VkKeyScan('w')))
	{
		z += 1;
		moved = true;
	}

	if (InputManager::GetInstance()->IsKeyPressed(VkKeyScan('a')))
	{
		x += -1;
		moved = true;
	}

	if (InputManager::GetInstance()->IsKeyPressed(VkKeyScan('s')))
	{
		z += -1;
		moved = true;
	}

	if (InputManager::GetInstance()->IsKeyPressed(VkKeyScan('d')))
	{
		x += 1;
		moved = true;
	}

	DirectX::XMVECTOR tempVector = DirectX::XMLoadFloat3(&DirectX::XMFLOAT3(x, y, z));
	tempVector = DirectX::XMVector3Normalize(tempVector);
	DirectX::XMFLOAT3 tempFloat;
	DirectX::XMStoreFloat3(&tempFloat, tempVector);
	SetDirection(tempFloat);
	AnimatedObject::HandleInput(tempFloat);

	return moved;
}
Beispiel #14
0
    void WorldNode::LookAt(const Vector3& LookAt, const Mezzanine::TransformSpace& TS, const Vector3& LocalDirection)
    {
        Vector3 Origin;
        switch(TS)
        {
        default:
        case Mezzanine::TS_World:
            Origin = GetLocation();
            break;
        case Mezzanine::TS_Parent:
            Origin = GetLocalLocation();
            break;
        case Mezzanine::TS_Local:
            Origin.Zero();
            break;
        }

        SetDirection(LookAt - Origin,TS,LocalDirection);
    }
Beispiel #15
0
void NaGeOneAxis2D::Mirror(const NaGeOneAxis2D& Ax)
{
	NaGePoint2D P = Position;
	NaGeVector2D D = Direction;
	/*CString str;
	str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	P.Mirror(Ax);
	NaGeVector2D dir = Ax.GetDirection();
	if(dir.IsParallel(D))
		D.Mirror(Ax.GetDirection());
	else
		D.Mirror(Ax);
	/*str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY());
}
Beispiel #16
0
void Daggerstorm::Cast(ObjectRef user, ObjectRef enemy)
{
	for (int i = 0; i < 8; i++) {
		auto projectileObject = Object::Create();

		projectileObject->SetJustEnabled();

		static int projectileNumber = 0;
		std::string name = std::string("projectile") + std::to_string(projectileNumber++);
		projectileObject->SetName(name);

		auto projectileComp = projectileObject->AddComponent<ProjectileComponent>();
		auto spriteComp = projectileObject->AddComponent<SpriteComponent>();
		auto colliderComp = projectileObject->AddComponent<ColliderComponent>();

		Vector2f direction = directions[i];

		projectileComp->SetDirection(direction);
		projectileComp->SetSpeed(projectileSpeed);
		projectileComp->SetSpell(this);
		projectileComp->SetUser(user);
		projectileComp->SetCanApplyOnUser(false);

		spriteComp->SetTexture("dagger.png");
		spriteComp->SetSize(Vector2f(20, 40));

		colliderComp->InitShape("rectangle", "20, 20");
		colliderComp->SetIsStatic(false);
		colliderComp->SetIsPhantom(true);

		Vector2f userPos = user->GetComponent<SpriteComponent>()->GetSize();
		Vector2f startingPos = user->GetPos() + userPos/2.f;
		Vector2f projectileSize = spriteComp->GetSize();
		float magic = (sqrt(pow(projectileSize.x, 2) + pow(projectileSize.y, 2))) / 2;

		projectileObject->SetPos(startingPos +
			magic * direction);
		g_menuHandler->GetCurrentMenu()->AddChild(std::move(projectileObject));
	}

	r_cooldown = cooldown;

}
Beispiel #17
0
/*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  Method:   COBall::CImpIBall::CheckBounce

  Summary:  Internal utility method to check the current ball position,
            dimension, and direction data and determine if the ball has
            hit the internal WinRect bounding rectangle. If it has then
            the ball data is recalculated to achieve a "bounce" effect
            for the ball as it moves.

  Args:     void

  Modifies: ...

  Returns:  void
M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/
void COBall::CImpIBall::CheckBounce(void)
{
  POINT Pos, Dir, Dim;
  int   xNewPos, yNewPos, xNewDir, yNewDir;

  GetPosition(&Pos);
  GetDirection(&Dir);
  GetDimensions(&Dim);

  // Check each edge of the client rectangle.  If the ball goes past the
  // boundries, reset its position and direction to give it a "bounce"
  // effect the next time it is displayed.
  xNewDir = Dir.x;
  yNewDir = Dir.y;
  xNewPos = Pos.x + Dir.x;
  yNewPos = Pos.y + Dir.y;

  if(xNewPos < m_WinRect.left)
  {
    xNewDir = ((lRandom() % m_xSkew) + m_xSkew);
    SetPosition(m_WinRect.left, Pos.y);
  }
  if((xNewPos + Dim.x) > m_WinRect.right)
  {
    xNewDir = -(((int)lRandom() % m_xSkew) + m_xSkew);
    SetPosition(m_WinRect.right - Dim.x, Pos.y);
  }
  if(yNewPos < m_WinRect.top)
  {
    yNewDir = ((lRandom() % m_ySkew) + m_ySkew);
    SetPosition(Pos.x, m_WinRect.top);
  }
  if((yNewPos + Dim.y) > m_WinRect.bottom)
  {
    yNewDir = -(((int)lRandom() % m_ySkew) + m_ySkew);
    SetPosition(Pos.x, m_WinRect.bottom - Dim.y);
  }

  SetDirection(xNewDir, yNewDir);

  return;
}
Beispiel #18
0
NPC::NPC(CL_GraphicContext *gc, CL_ResourceManager& resources, int posX, int posY, char* objectType)
	: Character(gc, resources, posX, posY, objectType)
{
	//ugly hack to fix the movement
	//TODO: fix movement and jump so they don't need this
	m_speedY = m_speeds[eYSpeed];
	m_speedX = m_speeds[eXSpeed]; 

	//TODO: set these dynamically
	if (posX > 600) {
		SetDirection(eLeft);
	}

	char ConfigFilePath[256] = "ObjectData/Characters/";
	strcat_s(ConfigFilePath, objectType);
	strcat_s(ConfigFilePath, ".xml");
	XmlParser parser(ConfigFilePath);

	NPC::Initialize(parser, resources);
}
Beispiel #19
0
bool RuntimeSpriteObject::SetAngle(float newAngle)
{
    if ( currentAnimation >= GetAnimationsCount() ) return false;

    if ( !animations[currentAnimation].Get().useMultipleDirections )
    {
        currentAngle = newAngle;

        needUpdateCurrentSprite = true;
    }
    else
    {
        newAngle = static_cast<int>(newAngle)%360;
        if ( newAngle < 0 ) newAngle += 360;

        return SetDirection(static_cast<int>(GDRound(newAngle/45.f))%8);
    }

    return true;
}
Beispiel #20
0
void ZActor::OnBlast(rvector &dir)
{
	if (!CheckFlag(AF_MY_CONTROL)) return;

	if (m_pNPCInfo->bNeverBlasted) return;

	rvector act_dir = GetDirection();
	act_dir.x = -dir.x;
	act_dir.y = -dir.y;
	SetDirection(act_dir);


	SetVelocity(dir * 300.f + rvector(0,0,1700.f));
	m_fDelayTime =3.0f;

	SetFlag(AF_BLAST, true);
	SetFlag(AF_LAND, false);

	m_Animation.Input(ZA_EVENT_BLAST);	
}
void ModifiedFlood (location_t here)
{
  direction_t direction;
  cost_t smallestCost;
  ListReset();
  ListAdd (here);
  while (!ListIsEmpty()) {
    here = ListStackPop();
    if (Cost (here) == 0) {
      continue;
    }
    direction = SmallestNeighbourDirection (here);
    smallestCost = Cost (Neighbour (here, direction));
    SetDirection (here, direction);
    if (Cost (here) != smallestCost + 1) {
      SetCost (here, smallestCost + 1);
      AddOpenNeighboursToList (here);
    }
  }
}
Beispiel #22
0
void MovingObjectModel::calcDirection()
{
	if(m_Path != NULL && !m_Path->empty())
	{
		auto next = m_Path->at(0);

		auto pos = GetPosition();

		Point tempDirection = next - pos;

		tempDirection = tempDirection.GetNormalizedPoint(); 
		if(m_Owner != NULL)
		{
			m_Owner->setLookAt2D(tempDirection.X, tempDirection.Y);
		}
		else
		{
			SetDirection(tempDirection.X, tempDirection.Y);
		}
	}
}
CLangData& CLangData::operator=(const CLangData& rSrc)
{
	if(this != &rSrc)
	{
		SetFilename(rSrc.GetFilename(true));
		SetLangName(rSrc.GetLangName());
		SetFontFace(rSrc.GetFontFace());
		SetPointSize(rSrc.GetPointSize());
		SetDirection(rSrc.GetDirection());
		SetHelpName(rSrc.GetHelpName());
		SetAuthor(rSrc.GetAuthor());
		m_bRTL = rSrc.m_bRTL;
		m_bUpdating = rSrc.m_bUpdating;
		m_uiSectionID = rSrc.m_uiSectionID;
		m_wPointSize = rSrc.m_wPointSize;
		m_bModified = false;

		m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end());
	}

	return *this;
}
CLangData::CLangData(const CLangData& ld) :
	m_pszFilename(NULL),
	m_pszLngName(NULL),
	m_pszFontFace(NULL),
	m_pszHelpName(NULL),
	m_pszAuthor(NULL),
	m_bRTL(ld.m_bRTL),
	m_bUpdating(ld.m_bUpdating),
	m_uiSectionID(ld.m_uiSectionID),
	m_wPointSize(ld.m_wPointSize),
	m_bModified(false)
{
	SetFilename(ld.GetFilename(true));
	SetLangName(ld.GetLangName());
	SetFontFace(ld.GetFontFace());
	SetPointSize(ld.GetPointSize());
	SetDirection(ld.GetDirection());
	SetHelpName(ld.GetHelpName());
	SetAuthor(ld.GetAuthor());

	m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end());
}
Beispiel #25
0
void Camera::RotateYaw3rd(float num)
{


	Vec3 tempCenter(World::Instance()->GetMainCharacter()->getPos().getX(),
		            World::Instance()->GetMainCharacter()->getPos().getY(),
					World::Instance()->GetMainCharacter()->getPos().getZ());

	Vec3 tempCamer(Position.getX(),
		           Position.getY(),
				   Position.getZ());

	tempCamer.rotateByPoint(tempCenter, -num/30);
	SetPosition(tempCamer);


	static float Rotation = 0;
	Rotation += num/30;

	if(Rotation < 0)
	{
		Rotation += 360;
	}
	else if(Rotation > 360)
	{
		Rotation -= 360; 
	}

	//just for rotate the Character
	World::Instance()->GetMainCharacter()->setRotation(0,Rotation, 0);
	
	Quaternion rotation(Up, num/30);
	Quaternion Conjugate = rotation.conjugate();
	Quaternion result =  (rotation.mult(Direction)).mult(Conjugate);
	SetDirection(Vec3(result.getX(), result.getY(), result.getZ()));

	UpdateRotation();
}
Beispiel #26
0
//-----------------------------------------------------------------------------//
// DestPos 위치로 이동한다.
// DestPos : 목적 위치
// bDash : TRUE=달려가기, FALSE=걷기
//-----------------------------------------------------------------------------//
void CCharacter::Move( const Vector3 &DestPos, BOOL bDash ) // bDash = FALSE
{
	Vector3 curpos = m_pModel[ BODY]->GetPos();
	Vector3 dir = DestPos - curpos;
	float len = dir.Length();
	float v = (bDash)? 0.10f : 0.05f;
	float t = len / v;
	if( 200.f > t ) return;

	STATE state = (bDash)? DASH : WALK;
	BOOL _continue = (m_State == state);
	SetAnimation( (bDash)? "dash":"walk", (int)t, _continue, FALSE, FALSE );

	dir.y = 0;
	dir.Normalize();
	SetDirection( dir );

	m_State = state;
	m_DestPos = DestPos;
	m_Dir = dir;
	m_Velocity = v;

}
Beispiel #27
0
SceneCamera::SceneCamera(const Camera& obj) : StageObject(obj.GetPosition(),GusVec3(1.0f,1.0f,1.0f),obj.GetDirection()),
    control(),
    currentType(CONTROL_TYPE::CHARACTER),
    cameraControl(*this),
    cameraFocusControl(*this),
    cameraFreeControl(*this),
    cameraAutoControl(*this),
    originalPosition(obj.GetPosition()),
	inversed(false)
{
    name = obj._GetName();
    SetDirection(obj.GetDirection());
    group.push_back(obj._GetId());
    
    control[CONTROL_TYPE::CHARACTER]    = &cameraControl;
    control[CONTROL_TYPE::CAMERA_FOCUS] = &cameraFocusControl;
    control[CONTROL_TYPE::CAMERA_FREE]  = &cameraFreeControl;
    control[CONTROL_TYPE::CAMERA_FREE]  = &cameraFreeControl;
    control[CONTROL_TYPE::AUTO_CONTROL]  = &cameraAutoControl;
    
    
    obj.SetStageRef(*this);
}
Beispiel #28
0
ReturnCodeSetSpeed CCar::SetSpeed(const int & speed)
{
	ReturnCodeSetSpeed wasError = ReturnCodeSetSpeed::SpeedOn;
	auto it = SPEED_RANGE.find(m_gear);
	if (!m_engineLaunched)
	{
		wasError = ReturnCodeSetSpeed::SpeedNotWithEngine;
	}
	else if (m_gear == 0 && speed > m_speed)
	{
		wasError = ReturnCodeSetSpeed::SpeedNotAddWithNeutralGear;
	}
	else if (!CheckBound(speed, it->second))
	{
		wasError = ReturnCodeSetSpeed::SpeedNotRange;
	}
	else
	{
		m_speed = speed;
		SetDirection();
	}
	return wasError;
}
Beispiel #29
0
void Game_Event::MoveTypeRandom() {
	int last_direction = GetDirection();
	switch (Utils::GetRandomNumber(0, 5)) {
	case 0:
		stop_count -= Utils::GetRandomNumber(0, stop_count);
		if (stop_count < 0) {
			stop_count = 0;
		}
		return;
	case 1:
		MoveForward();
		break;
	default:
		MoveRandom();
	}
	if (move_failed && !starting) {
		SetDirection(last_direction);
		if (!(IsDirectionFixed() || IsFacingLocked()))
			SetSpriteDirection(last_direction);
	} else {
		max_stop_count = max_stop_count / 5 * Utils::GetRandomNumber(3, 6);
	}
}
Beispiel #30
0
void Game_Player::PerformTeleport() {
	if (!teleporting) return;

	teleporting = false;

	if (Game_Map::GetMapId() != new_map_id) {
		Refresh(); // Reset sprite if it was changed by a move
		Game_Map::Update(); // Execute remaining events (e.g. ones listed after a teleport)
		Game_Map::Setup(new_map_id);
		last_pan_x = 0;
		last_pan_y = 0;
	}

	SetOpacity(255);

	MoveTo(new_x, new_y);
	if (new_direction >= 0) {
		SetDirection(new_direction);
		SetSpriteDirection(new_direction);
	}

	if (InVehicle())
		GetVehicle()->MoveTo(new_x, new_y);
}