13 constexpr
float RotateSpeed = 120.f;
14 constexpr
float FadeTime = 1.6f;
15 constexpr
float ProfMoveSpeedX = -550.f;
16 constexpr
float ProfMoveSpeedY = 450.f;
17 constexpr
float ProfRotateSpeed = -75.f;
23 :
State(systems,
bl::engine::StateMask::Menu)
30 bgndTxtr = engine.renderer().texturePool().getOrLoadTexture(bl::util::FileUtil::joinPath(
32 profTxtr = engine.renderer().texturePool().getOrLoadTexture(bl::util::FileUtil::joinPath(
35 background.create(engine, bgndTxtr);
36 background.getTransform().setOrigin(bgndTxtr->size() * 0.5f);
40 prof.create(engine, profTxtr);
41 prof.getTransform().setPosition(background.getTransform().getLocalPosition() -
42 profTxtr->size() * 0.5f);
43 prof.getTransform().setDepth(-1.f);
46 auto overlay = engine.renderer().getObserver().pushScene<bl::rc::Overlay>();
47 background.addToScene(overlay, bl::rc::UpdateSpeed::Dynamic);
48 prof.addToScene(overlay, bl::rc::UpdateSpeed::Dynamic);
52 "just call me Professor Professor");
54 "Your mom told me she had a kid, but I wasn't really listening. What's your name?",
57 std::bind(&NewGame::nameSet,
this, std::placeholders::_1));
60 void NewGame::nameSet(
const std::string& n) {
64 "It's hard to tell with, uh... my bad vision, but are you a boy or a girl?",
66 std::bind(&NewGame::genderSet,
this, std::placeholders::_1));
69 void NewGame::genderSet(
const std::string& g) {
73 "sure you'll figure the rest out",
74 std::bind(&NewGame::fadeOut,
this));
77 void NewGame::fadeOut() {
82 .putTask<bl::rc::rgi::FadeEffectTask>(FadeTime);
86 engine.renderer().getObserver().popScene();
90 BL_LOG_ERROR <<
"Failed to load starting map";
99 background.getTransform().rotate(RotateSpeed * dt);
103 if (prof.getTransform().getRotation() > -90.f) {
104 prof.getTransform().rotate(dt * ProfRotateSpeed);
106 prof.getTransform().move({dt * ProfMoveSpeedX, dt * ProfMoveSpeedY});
Parent namespace for all functionality unique to the game.
static const std::string & MenuImagePath()
static sf::Vector2f WindowSize()
void set(const Time &time)
Sets the current time.
void displayMessage(const std::string &message, const Callback &cb=[](const std::string &) {})
Displays a message in the HUD textbox. Messages are queued in order that they arrive.
void promptUser(const std::string &prompt, const std::vector< std::string > &choices, const Callback &cb)
Asks the player a question through the HUD.
void getInputString(const std::string &prompt, unsigned int minLen, unsigned int maxLen, const Callback &cb)
Prompts the player to input a string using the screen keyboard.
void newGame(const std::string &name, player::Gender gender)
Initializes all player data structures for a new game.
Owns all primary systems and a reference to the engine.
const bl::engine::Engine & engine() const
Const accessor for the Engine.
Player & player()
Returns the player system.
Clock & clock()
Accessor for the in game clock.
HUD & hud()
Returns the HUD.
World & world()
Modifiable accessor for the world system.
bool switchMaps(const std::string &newMap, int spawnId)
Switches the current map to the map in the given file.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates the main game state. The game state must be initialized before invoking the main game state.
This state does the game intro, gets the player's name and gender, and triggers the main game state i...
virtual void activate(bl::engine::Engine &engine) override
Activates the state.
virtual const char * name() const override
Returns "NewGame".
virtual void deactivate(bl::engine::Engine &engine) override
Deactivates the state.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates the new game state.
virtual void update(bl::engine::Engine &engine, float dt, float) override
Updates the state and menus and whatnot.
Parent to all game states. Provides some commonly required data like core game systems.
core::system::Systems & systems