Пример #1
0
void ActorBarline::Run(double TimeDelta, double Ratio)
{
	if (AnimationProgress > 0)
	{
		float PosY = pow(AnimationProgress / AnimationTime, 2) * PlayfieldHeight + ScreenOffset;

		Alpha = 1 - AnimationProgress;

		SetPositionY(PosY);
		AnimationProgress -= TimeDelta;

		if (AnimationProgress <= 0)
			AnimationProgress = 0;
		
		return; 
	}
	
	if (Parent->GetMeasure() % 2)
	{
		Red = 1;
		Blue = Green = 0;

		if (Ratio > RadioThreshold) // Red to blue
		{
			double diff = Ratio - RadioThreshold;
			double duration = (1 - RadioThreshold);

			Red = LerpRatio(1.0, 0.0, diff, duration );
			Blue = LerpRatio(0.0, BLUE_CONSTANT, diff, duration);
		}
	}else
	{
		Red = 0.0;
		Blue = 200.f / 255.f;

		if (Ratio > RadioThreshold) // Blue to red
		{
			float diff = Ratio - RadioThreshold;
			double duration = (1 - RadioThreshold);

			Red = LerpRatio(0.0, 1.0, diff, duration);
			Blue = LerpRatio(BLUE_CONSTANT, 0.0, diff, duration);
		}
	}

	SetPositionY(Ratio * (float)PlayfieldHeight);
			
	if (Parent->GetMeasure() % 2)
		SetPositionY(PlayfieldHeight - GetPosition().y);

	SetPositionY(GetPosition().y + ScreenOffset);

	// assert(GetPosition().y > ScreenOffset);
}
Пример #2
0
bool Dialog::CreateFromXML(const char* idd){
	ScopedPointer<File> fh = gUiRender->OpenFile(idd);
	if(!fh) return false;
	char* xml = (char*)fh->ReadWholeFile();
	int tmpInt;
	bool result = true;
	
	try {
		ticpp::Document doc;
		doc.Parse(xml);

		ticpp::Element* root = doc.FirstChildElement("Root_Element");
		if(root->GetAttribute("ID", &tmpInt))			SetID(tmpInt);
		if(root->GetAttribute("X", &tmpInt))			SetPositionX(tmpInt);
		if(root->GetAttribute("Y", &tmpInt))			SetPositionY(tmpInt);
		if(root->GetAttribute("WIDTH", &tmpInt))		SetSizeX(tmpInt);
		if(root->GetAttribute("HEIGHT", &tmpInt))		SetSizeY(tmpInt);
		if(root->GetAttribute("MODAL", &tmpInt))		SetModal(tmpInt);
		if(root->GetAttribute("SHOWSID", &tmpInt))		SetShowSoundID(tmpInt);
		if(root->GetAttribute("HIDESID", &tmpInt))		SetHideSoundID(tmpInt);
		if(root->GetAttribute("EXTENT", &tmpInt))		SetExtent(tmpInt);
		if(root->GetAttribute("DEFAULT_X", &tmpInt))	SetDefaultPositionX(tmpInt);
		if(root->GetAttribute("DEFAULT_Y", &tmpInt))	SetDefaultPositionY(tmpInt);
		if(root->GetAttribute("ADJUST_X", &tmpInt))		SetDefaultAdjustPositionX(tmpInt);
		if(root->GetAttribute("ADJUST_Y", &tmpInt))		SetDefaultAdjustPositionY(tmpInt);
		if(root->GetAttribute("DEFAULT_VISIBLE", &tmpInt)) SetDefaultVisible(tmpInt);
		SetName(root->GetAttribute("NAME").c_str());
		
		for(ticpp::Element* child = root->FirstChildElement(false); child; child = child->NextSiblingElement(false)){
			if(child->Value() == "CAPTION"){
				mCaption = (Caption*)CreateControlFromXML(child, this);
			}else if(child->Value() == "RADIOBUTTON"){
				RadioButton* btn = (RadioButton*)CreateControlFromXML(child, this);
				if(int id = btn->RadioBoxID()){
					RadioBox* box = (RadioBox*)GetControlByID(id);
					if(box && box->ControlType() == CT_RADIOBOX)
						box->AddButton(btn);
				}

				AddChild(btn);
			}else{
				AddChild(CreateControlFromXML(child, this));
			}
		}

	}catch(ticpp::Exception& ex){
		LOG("TinyXML Exception %s", ex.what());
		result = false;
	}

	OnCreated();

	delete [] xml;
	return result;
}
Пример #3
0
void Player::Update(float dt)
{
	m_animator->Animate(dt);
	if (movementX != 0 && movementY != 0)
	{
		movementX /= 1.41f;
		movementY /= 1.41f;
	}
	managePlayersTextureDirection();
	SetPositionX(GetPositionX() + movementX);
	SetPositionY(GetPositionY() + movementY);
	m_sprite.setPosition(GetPositionX(),GetPositionY());

	if (m_bomb != nullptr)
	{
		m_bomb->Update(dt);
		if (m_bomb->GetState() == Bomb::exploding)
		{
			level->DestroyTile(m_bomb->GetPositionInTileCoordinatesX(), m_bomb->GetPositionInTileCoordinatesY(), false);
		}
		if (m_bomb->GetState() == Bomb::exploded)
		{
			delete m_bomb;
			m_bomb = nullptr;
		}
	}
	if (m_respawns > 0 && m_respawns < m_maxNumberOfRespawns && (m_respawnClock.getElapsedTime() >= m_respawnSafeTime))
	{
		m_canBeDamaged = true;
	}
	else if (m_respawns <= 0 && m_isAlive)
	{
		endGame();
		m_isAlive = false;
	}
	else
	{
		m_isAlive = true;
	}
}
Пример #4
0
void BonusTile::Update()
{
    if (IsRemoved())
        return;

    if (GAME_STATE_PAUSED(sGame.GetGameState()))
    {
        Draw(animationFinished ? &imageUsed : NULL, true);
        return;
    }

    SpecialTile::Update();

    if (isUsed && animating && !animationFinished)
    {
        animating = true;

        if (movingUp)
        {
            SetPositionY(GetPositionY() - 9.0f);

            if (GetPositionY() < startPosition.y - 40.0f)
                movingUp = false;
        }
        else
        {
            SetPositionY(GetPositionY() + 9.0f);

            if (GetPositionY() >= startPosition.y)
            {
                SetPositionY(startPosition.y);
                movingUp = true;
                animating = false;
                animationFinished = true;
                sf::Texture imageCoin;
                imageCoin.loadFromFile("Graphics/Tiles/coin_gold.png");

                switch (urand(0, 1))
                {
                    case 0:
                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));
                        break;
                    case 1:
                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));
                        break;
                    default:
                        std::cout << "Typo in BonusTile::Update switch (urand)" << std::endl;
                        break;
                }
            }
        }
    }

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::F2))
    {
        SetPosition(startPosition.x, startPosition.y);
        animationFinished = false;
        movingUp = true;
    }

    Draw(animationFinished ? &imageUsed : NULL, true);
}
Пример #5
0
void Player::Spawn()
{
	SetPositionX(static_cast<int>(m_respawnPosition.x*TILE_SIZE + TILE_SIZE / 2));
	SetPositionY(static_cast<int>(m_respawnPosition.y*TILE_SIZE + TILE_SIZE / 2));
}
Пример #6
0
void Unit::Update()
{
    if (typeId == TYPEID_MENU_PLAYER || (GAME_STATE_PAUSED(sGame.GetGameState()) && isAlive))
    {
        Draw(NULL, typeId == TYPEID_MENU_PLAYER);
        return;
    }

    if (sGame.GetGameState() == STATE_MAIN_MENU || !isAlive)
        return;

    if (hasBounced)
    {
        float newX = bounceToLeft ? GetPositionX() - bounceSpeed : GetPositionX() + bounceSpeed;

        if (!CollidesWithGameobjects(newX, GetPositionY()))
        {
            SetPosition(newX, GetPositionY());
            bounceSpeed--;
        }

        if (bounceSpeed <= 0)
            hasBounced = false;
    }

    if (isJumping)
    {
        if (jumpSpeed && !CollidesWithGameobjects(GetPositionX(), GetPositionY() - jumpSpeed))
        {
            SetPositionY(GetPositionY() - jumpSpeed);
            jumpSpeed--;
        }
        else
        {
            isJumping = false;
            isFalling = true;
            jumpSpeed = 15;
        }
    }
    else if (!canFly)
    {
        if (!isOnMovingTile)
        {
            if ((!fallSpeed && !CollidesWithGameobjects(GetPositionX(), GetPositionY() + 1.0f)) || (fallSpeed && !CollidesWithGameobjects(GetPositionX(), GetPositionY() + fallSpeed)))
            {
                isFalling = true;
                SetPositionY(GetPositionY() + fallSpeed);
                fallSpeed++;
            }
            else
            {
                isFalling = false;
                fallSpeed = 0;
            }
        }
        else
        {
            isJumping = false;
            isFalling = false;
            fallSpeed = 0;
        }
    }

    Draw(NULL, true);
}
Пример #7
0
/*!
@brief 設定ウィンドウの座標設定
@par   関数説明
ウィンドウの座標を設定する。設定反映はSetWindow()関数を使う。
@param unsigned int x X座標を与える。
@param unsigned int y Y座標を与える。
@return 0を返す。
*/
int Window::SetPositionXY( int x, int y )
{
	SetPositionX( x );
	SetPositionY( y );
	return 0;
}
Пример #8
0
/*!
@brief ウィンドウの設定を変更する
@par   関数説明
ウィンドウスタイルを設定する。
@param Type WT_で始まる定数。
@return false=設定反映かSetWindowPosでの設定失敗。
@return true=SetWindowPosでの設定成功。
*/
BOOL Window::SetWindow( int type, int display )
{
	HWND myhwnd = NULL;//ウィンドウハンドル
	RECT myrect;//RECT構造体
	BOOL ret;

	// ディスプレイ番号から領域を割り出して移動してからサイズ変更とかを行うように書き換え

	switch ( type )
	{
	case WT_DEFAULT://サイズ固定のウィンドウ
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_DEFAULT );
		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOP;
		//ウィンドウのサイズや位置を変更
		ret = SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),//CW_USEDEFAULT, CW_USEDEFAULT,
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
		SetPositionX( GetPositionX( 1 ) );
		SetPositionY( GetPositionY( 1 ) );
		return ret;
	case WT_NORMAL://通常のリサイズ可能ウィンドウ
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NORMAL );
		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		//ウィンドウのサイズや位置を変更
		wd.winpos = HWND_TOP;
		ret = SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),//CW_USEDEFAULT, CW_USEDEFAULT,
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
		SetPositionX( GetPositionX( 1 ) );
		SetPositionY( GetPositionY( 1 ) );
		return ret;
	case WT_NOFRAME:
	case WT_FULLSCREEN:
		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NOFRAME );

		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOP;
		//ウィンドウのサイズや位置を変更
		return SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);
	case WT_NORESIZEFULLSCREEN://画面設定を変えないフルスクリーン
		//プログラムを起動したデスクトップサイズのウィンドウで
		//描写優先度が一番上のウィンドウを生成する

		//ウィンドウスタイルの設定
		SetWindowStyle( WT_NORESIZEFULLSCREEN );

		// 対象ディスプレイのサイズなどを取得。
		if ( GetDisplayRect( display, &myrect ) == 0 )
		{
			// 成功したので、うまい具合に設定。
			// 位置はディスプレイの左上。
			SetPositionXY( myrect.left, myrect.top );
			// サイズはディスプレイに合わせる。
			SetWindowSize( myrect.right - myrect.left, myrect.bottom - myrect.top );
		} else
		{
			// 失敗したので、デスクトップから取得。

			//デスクトップのウィンドウハンドル取得
			myhwnd = GetDesktopWindow();
			//デスクトップのサイズなどを取得
			if ( myhwnd && GetClientRect( myhwnd, &myrect ) )
			{
				//位置は原点に設定
				SetPositionXY( 0, 0 );
				//サイズはデスクトップと同じサイズに設定
				SetWindowSize( myrect.right, myrect.bottom );
			}
		}

		//ウィンドウスタイルの変更
		SetWindowLong( GetWindowHandle(), GWL_STYLE, GetWindowStyle() );
		wd.flags = SWP_SHOWWINDOW;
		wd.winpos = HWND_TOPMOST;
		//ウィンドウのサイズや位置を変更
		return SetWindowPos(
			GetWindowHandle(), wd.winpos,
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			wd.flags
			);

	default:
		//後で考える
		//リサイズ程度
		MoveWindow(
			GetWindowHandle(),
			GetPositionX(), GetPositionY(),
			GetWindowWidth(), GetWindowHeight(),
			TRUE
			);
		break;
	}
	return 0;
}
Пример #9
0
void SceneObject::SetPosition(float x, float y, float z)
{
	SetPositionX(x);
	SetPositionY(y);
	SetPositionZ(z);
}