Example #1
0
void StageGUI::Update(double dt)
{
	if (popup)
	{
		if (popup->GetComponent<Button>()->IsState())
			Engine.ChangeState(&MenuState::Instance());
	}

	wave->SetText(ToString("Wave ", stage->currentWave + 1).c_str());
	timer->SetText(ToString("Time: ", (int)(stage->waveTimer + 0.5f)).c_str());
	health->SetText(ToString(stage->health, "HP").c_str());
	gold->SetText(ToString(stage->gold, 'G').c_str());

	switch (stage->state)
	{
	case StageManager::FREETIME:
		pause->text->SetText("START");
		break;
	case StageManager::WAVE:
		pause->text->SetText("PAUSE");
		break;
	case StageManager::PAUSED:
		pause->text->SetText("RESUME");
		break;
	}

	Fall(indicator->color.w, Time.GetUnscaledTime() * 0.6f, 0);

	if (quit->IsState())
		quitPopup->GetComponent<StandardPopup>()->PopUp("Return to Main Menu?");

	if (quitPopup->IsActive() && quitPopup->GetComponent<StandardPopup>()->IsOK())
		Engine.ChangeState(&MenuState::Instance());
}
Example #2
0
void Fall_Block::Stoped()
{
	if (fall_block->stop_flag != true || fall_flag != true)
		return;

	Fall();

	if (fall_block->pos.y() + fall_block->size.y() < -WIN_HEIGHT / 2)
		fall_flag = false;
}
Countdown::Countdown()
{
	m_falls.push_back(Fall(0));             // bottom 0
	m_falls.push_back(Fall(TIME_CLICK * 2)); // bottom 2

	// *2 方式建立 fall
	m_falls.push_back(Fall(TIME_CLICK * 5));
	m_falls.push_back(Fall(TIME_CLICK * 11));
	m_falls.push_back(Fall(TIME_CLICK * 23));
	m_falls.push_back(Fall(TIME_CLICK * 47));
	m_falls.push_back(Fall(TIME_CLICK * 97));
	m_falls.push_back(Fall(TIME_CLICK * 197));
	m_falls.push_back(Fall(TIME_CLICK * 397));

	m_falls_last_idx = m_falls.size() - 1;
}
Example #4
0
void Entity::CheckCollisionsWithLevel(double dt, LevelPtr level) {
    // czy jednostka koliduje z czymś od góry
    if(IsAnyFieldAboveMe(dt, level)) {
        Fall();  // rozpocznij spadanie
    }

    // czy jednostka koliduje z czymś od dołu
    if(IsAnyFieldBelowMe(dt, level)) {
        EntityOnGround();   // zatrzymaj na podłożu
    }

    // czy jednostka koliduje z czymś po lewej stronie
    if(IsAnyFieldOnLeft(dt, level)) {
        NegateXVelocity();  // zawróć
    }

    // czy jednostka koliduje z czymś po prawej stronie
    if(IsAnyFieldOnRight(dt, level)) {
        NegateXVelocity();  // zawróć
    }
}
Example #5
0
int main() {
	Begin();
	Start();
	Draw();
	for (; Create();) {
		Refresh();
		bool next = true;
		for (int a = 0; next; a++) {
			int limit = 50000 / level;
			if (!pause && a > limit) {
				a = 0;
				next = Fall();
				Refresh();
			}
			if (kbhit()) {
				next = Load();
				Refresh();
			}
			BonusPauses();
		}
	}
	return 0;
}
Example #6
0
bool Load() // keys
{
	bool correct = true;
	char typedChar = getch();
	switch (typedChar) {
	case 72:
		if (!pause) Rotate();
		break;
	case 80:
		if (!pause) correct = Fall();
		break;
	case 75:
		if (!pause) To_Left();
		break;
	case 77:
		if (!pause) To_Right();
		break;
	case 112:
		ButtonPause();
		break;
	}
	return correct;
}
Example #7
0
void Player::CheckCollisionsWithLevel(double dt, LevelPtr level) {
    size_t x_tile, y_tile;
    GetCurrentTile(&x_tile, &y_tile);

    // czy gracz wszedł w portal i należy mu się wygrana :)
    for (int i=-1; i<2; i++) {
        for (int j=-1; j<2; j++) {
            if (static_cast<int>(x_tile) + i < 0 || static_cast<int>(y_tile) + j < 0)
                continue;
            if (level->GetFieldAabb(x_tile + i, y_tile + j).Collides(GetNextAabb(dt))
                    && level->Field(x_tile + i, y_tile + j) == FT::EndOfLevel) {
                LevelCompleted();
            }
        }
    }

    // czy postać koliduje z czymś od góry
    if (IsAnyFieldAboveMe(dt, level)) {
        Fall();
    }

    // czy postać koliduje z czymś od dołu
    if (IsAnyFieldBelowMe(dt, level)) {
        PlayerOnGround();
    }

    // czy postać koliduje z czymś po lewej stronie
    if (IsAnyFieldOnLeft(dt, level)) {
        ForbidGoingLeft();
    }

    // czy postać koliduje z czymś po prawej stronie
    if (IsAnyFieldOnRight(dt, level)) {
        ForbidGoingRight();
    }
}
/*
	ライト応答
*/
void LightKobitoBlue::ResponseAo()
{
	Fall();
}
Example #9
0
void	MoveMouse( void )
{
static	int	locked = 0;
	int		k;

	if ( locked )
	{
		locked--;
		actcode=0xee;
		return;
	}
	k=0;
	switch( actcode )
	{
	case RC_7 : k++;
	case RC_6 : k++;
	case RC_5 : k++;
	case RC_4 : k++;
	case RC_3 : k++;
	case RC_2 : k++;
	case RC_1 : k++;
		break;
	}
	if ( k )
		ipos=k-1;
	switch( actcode )
	{
	case RC_RIGHT :
		if ( ipos < 6 )
		{
			FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK );
			ipos++;
			FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
			locked=1;
		}
		break;
	case RC_LEFT :
		if ( ipos > 0 )
		{
			FBFillRect( ipos*48+64+6, 48+4, 36, 40, BLACK );
			ipos--;
			FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
			locked=1;
		}
		break;
	case RC_7 :
	case RC_6 :
	case RC_5 :
	case RC_4 :
	case RC_3 :
	case RC_2 :
	case RC_1 :

	case RC_OK :
		locked=1;
		if ( maze[ipos+35] )
			break;
		Fall( ipos, dred, 1 );
		k=TestGameOver( 1 );
		if ( GameOver(1) )
			return;
		MyPlay();
		if ( GameOver(2) )
			return;
		ipos=3;
		FBOverlayImage( ipos*48+64+6, 48+4, 36, 40, 0, 0, WHITE,
				dred, 0,0,0);
		break;
	}
}
Example #10
0
static	void	CPlay( int x )
{
	FBOverlayImage( x*48+64+6, 48+4, 36, 40, 0, 0, WHITE, dblue, 0,0,0);
	msleep(700);
	Fall( x, dblue, 2 );
}
Example #11
0
void Cf3MapObjectfunya::OnMove()
{
	if (!IsValid()) return;
	if (!m_pParent->IsPlayable()) return;
	if (m_bFirst) { HitCheck(); m_bFirst = false; }
	float Wind = m_pParent->GetWind(floor(m_X/32),floor(m_Y/32));
	float Friction = m_pParent->GetFriction(floor(m_X/32),floor((m_Y+14)/32));
	float Gravity = GetGravity();
	if (m_pParent->ItemCompleted()) Smile();
	if (theSetting->m_Hyper) m_nPower=4;
	// 動かしま〜す
	if (m_State==STANDING||m_State==SLEEPING||m_State==BLINKING) {
		// 立ってるとき
		m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
		BringClose(m_DX,0.0f,Friction);
		if (m_DX==0) m_Direction = DIR_FRONT;
		if (m_State==STANDING && ++m_Sleepy>=30*40/3) Sleep();
		if (m_State==BLINKING && --m_PoseCounter==0) m_State = STANDING;
		if (m_State==STANDING && CApp::random(120)==0) Blink();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) Run(DIR_LEFT);
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) Run(DIR_RIGHT);
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==RUNNING) {
		// 走ってるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX -= Friction*(m_DX-Wind)*RUNFRICTION;
		m_DX += Friction*2.0f*(AXR-AXL);
		if (AXL&&!AXR) m_Direction = DIR_LEFT;
		if (AXR&&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&&!AXR) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==WALKING) {
		// 歩いてるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX += WALKACCEL*(AXR-AXL);
		m_DX -= m_DX*WALKFRICTION;
		if (AXL&!AXR) m_Direction = DIR_LEFT;
		if (AXR&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&!AXR) m_Direction = DIR_FRONT;
		if (!m_pInput->GetKeyPressed(F3KEY_DOWN)) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPushed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) Fall();
	}ef(m_State==CHARGING) {
		// パワー充填中
		if (m_ChargePower>0) {
			m_ChargePower -= m_ChargeDec;
			if (m_ChargePower<0) m_ChargePower = 0;
		}
		m_X -= m_DX;
		if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_pInput->GetKeyPressed(F3KEY_JUMP)) Jump();
		if (!m_HitBottom) Fall();
	}ef(m_State==JUMPING) {
		// 空中
		if (m_DY>=0) {
			int AXL = 0, AXR = 0;
			if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
			if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			m_DX += JUMPACCEL*(AXR-AXL);
			if (AXL&!AXR) m_Direction = DIR_LEFT;
			if (AXR&!AXL) m_Direction = DIR_RIGHT;
		}
		if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
		m_DY += Gravity;
		if (m_DY>=0) {
			if (m_PowerY>=0 && m_pInput->GetKeyPressed(F3KEY_DOWN)) m_DY += Gravity*ADDGRAVITY;
			m_DY -= m_DY*JUMPFRICTIONY;
			if (m_pInput->GetKeyPressed(F3KEY_UP)) {
				m_DY += Gravity;
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (m_HitBottom) Land();
	}ef(m_State==BREATHEIN) {
		// 冷気充填中
		m_ChargePower+=1.0f;
		if (m_pInput->GetKeyPushed(F3KEY_LEFT)) m_Direction = DIR_LEFT;
		if (m_pInput->GetKeyPushed(F3KEY_RIGHT)) m_Direction = DIR_RIGHT;
		if (m_pInput->GetKeyPushed(F3KEY_UP)) m_Direction = DIR_FRONT;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
			if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		}else {
			m_ChargePower+=1.0f;
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (!m_pInput->GetKeyPressed(F3KEY_ATTACK)) BreatheOut();
	}ef(m_State==BREATHEOUT) {
		// 冷気放出!!
		m_ChargePower-=1.0f;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_ChargePower<=0.0f) {
			if (m_nPower) {
				if (m_HitBottom) Land(); else Fall();
			}else {
				Tire();
			}
		}
	}ef(m_State==TIRED) {
		// ちかれたー!
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
			m_DY += Gravity;
			m_DY -= m_DY*JUMPFRICTIONY;
		}
		if (m_PoseCounter==0) Land();
	}ef(m_State==FROZEN) {
		// 凍っちゃった…
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION/5;
			BringClose(m_DX,0.0f,Friction/5);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX/5;
			m_DY += Gravity*(1+ADDGRAVITY);
			m_DY -= m_DY*JUMPFRICTIONY/5;
		}
		if (m_PoseCounter==0) Land();
	}
	// 速度飽和(めり込み防止)
	Saturate(-RUNMAX,m_DX,RUNMAX);
	Saturate(-JUMPMAX,m_DY,FALLMAX);
	// 実際の移動+当たり判定
	// 1回の移動ごとに当たり判定
	// という手順ですり抜けバグは解消されるはず
	m_HitLeft = m_HitRight = m_HitTop = m_HitBottom = false;
	m_X += m_DX;
	HitCheck();
	if (!m_HitTop&&!m_HitBottom) {
		m_Y += m_DY;
		HitCheck();
	}
}