Bouncing works but going too high causes an assertion.
This commit also reduces the jump size and the character's size.
This commit is contained in:
parent
df8f5ca6b2
commit
164030202c
9 changed files with 82 additions and 7 deletions
|
@ -46,6 +46,10 @@ namespace cloonel {
|
|||
CollisionID_Player,
|
||||
CollisionID_Enemies
|
||||
};
|
||||
|
||||
void OnCharacterBounce (MoverSine* parMover, const Line<float, 2>&, const float2&) {
|
||||
parMover->ResetToBounce();
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
||||
///--------------------------------------------------------------------------
|
||||
|
@ -70,9 +74,10 @@ namespace cloonel {
|
|||
void GameplaySceneClassic::OnPrepare() {
|
||||
const float halfRefHeight = static_cast<float>(REFERENCE_HEIGHT) / 2.0f;
|
||||
Collider& collider = *this->GetCollider();
|
||||
const float2 charaRefSize(static_cast<float>(REFERENCE_CHARA_WIDTH), static_cast<float>(REFERENCE_CHARA_HEIGHT));
|
||||
|
||||
std::unique_ptr<MoverSine> moverSine(new MoverSine());
|
||||
std::unique_ptr<Character> player(new Character("resources/graphics/player.png", SDLObject(), float2(80.0f, 120.0f)));
|
||||
std::unique_ptr<Character> player(new Character("resources/graphics/player.png", SDLObject(), charaRefSize));
|
||||
std::unique_ptr<MoverLeftRight> moverLeftRight(new MoverLeftRight(1.5f, 5.0f, 40.0f));
|
||||
std::unique_ptr<MoverWorld> moverWorld(new MoverWorld(halfRefHeight));
|
||||
std::unique_ptr<TiledWallpaper> wallpaper(new TiledWallpaper("resources/graphics/background_tile.png", SDLObject()));
|
||||
|
@ -97,6 +102,8 @@ namespace cloonel {
|
|||
platforms->RegisterForCollision(regPlatfCollision, unregPlatfCollision);
|
||||
}
|
||||
|
||||
player->SetOnBounceCallback(std::bind(&OnCharacterBounce, moverSine.get(), std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
std::swap(moverSine, m_moverSine);
|
||||
std::swap(player, m_player);
|
||||
std::swap(moverLeftRight, m_moverLeftRight);
|
||||
|
@ -111,7 +118,7 @@ namespace cloonel {
|
|||
m_platforms->AddDrawables();
|
||||
AddDrawable(m_player.get());
|
||||
|
||||
const float jumpPower = halfRefHeight * 1.29f;
|
||||
const float jumpPower = halfRefHeight * 0.71f;
|
||||
m_moverSine->SetPower(jumpPower);
|
||||
|
||||
collider.TieGroups(CollisionID_Platforms, CollisionID_Player);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue