Add some (badly) generated platforms that will scroll
down whenever the player's top side depasses the middle of the screen. WiP.
This commit is contained in:
parent
976d34f17e
commit
4a3a0a4782
13 changed files with 251 additions and 55 deletions
|
@ -24,9 +24,11 @@
|
|||
#include "inputbag.hpp"
|
||||
#include "key.hpp"
|
||||
#include "moverleftright.hpp"
|
||||
#include "moverworld.hpp"
|
||||
#include "tiledwallpaper.hpp"
|
||||
#include "texture.hpp"
|
||||
#include "platformsystem.hpp"
|
||||
#include "CloonelJumpConfig.h"
|
||||
#include <algorithm>
|
||||
#include <SDL2/SDL_scancode.h>
|
||||
#include <ciso646>
|
||||
|
@ -59,40 +61,52 @@ namespace cloonel {
|
|||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
void GameplaySceneClassic::Prepare() {
|
||||
const float halfRefHeight = static_cast<float>(REFERENCE_HEIGHT) / 2.0f;
|
||||
|
||||
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<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()));
|
||||
std::unique_ptr<PlatformSystem> platforms(new PlatformSystem("resources/graphics/platform.png", SDLObject(), this));
|
||||
std::unique_ptr<PlatformSystem> platforms(new PlatformSystem("resources/graphics/platform.png", SDLObject(), this, halfRefHeight * 0.9f, *moverWorld));
|
||||
|
||||
player->Prepare();
|
||||
moverSine->RegisterPlaceable(player.get());
|
||||
moverSine->RegisterPlaceable(moverWorld.get()); //Keep an invisible mover
|
||||
moverLeftRight->RegisterPlaceable(player.get());
|
||||
moverWorld->RegisterPlaceable(player.get()); //It compensates the position when the chara goes over the mid
|
||||
moverWorld->RegisterPlaceable(moverWorld.get()); //The mover has to be in sync with the character
|
||||
wallpaper->Reload();
|
||||
platforms->Prepare();
|
||||
|
||||
std::swap(moverSine, m_moverSine);
|
||||
std::swap(player, m_player);
|
||||
std::swap(moverLeftRight, m_moverLeftRight);
|
||||
std::swap(moverWorld, m_moverWorld);
|
||||
std::swap(wallpaper, m_wallpaper);
|
||||
std::swap(platforms, m_platforms);
|
||||
|
||||
AddMover(m_moverSine.get());
|
||||
AddMover(m_moverLeftRight.get());
|
||||
AddDrawable(m_wallpaper.get());
|
||||
AddMover(m_moverWorld.get());
|
||||
m_platforms->AddDrawables();
|
||||
AddDrawable(m_player.get());
|
||||
|
||||
m_moverSine->SetPower(static_cast<float>(SDLObject()->WidthHeight().y() / 2));
|
||||
const float jumpPower = halfRefHeight * 1.29f;
|
||||
m_moverSine->SetPower(jumpPower);
|
||||
}
|
||||
|
||||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
void GameplaySceneClassic::Destroy() noexcept {
|
||||
m_moverSine = std::move(std::unique_ptr<MoverSine>(nullptr));
|
||||
m_player = std::move(std::unique_ptr<Character>(nullptr));
|
||||
m_moverLeftRight = std::move(std::unique_ptr<MoverLeftRight>(nullptr));
|
||||
m_wallpaper = std::move(std::unique_ptr<TiledWallpaper>(nullptr));
|
||||
//Destroy in reverse creation order
|
||||
m_platforms = std::move(std::unique_ptr<PlatformSystem>(nullptr));
|
||||
m_wallpaper = std::move(std::unique_ptr<TiledWallpaper>(nullptr));
|
||||
m_moverWorld = std::move(std::unique_ptr<MoverWorld>(nullptr));
|
||||
m_moverLeftRight = std::move(std::unique_ptr<MoverLeftRight>(nullptr));
|
||||
m_player = std::move(std::unique_ptr<Character>(nullptr));
|
||||
m_moverSine = std::move(std::unique_ptr<MoverSine>(nullptr));
|
||||
}
|
||||
|
||||
///--------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue