/// Renders the title screen. /// @param[in,out] renderer - The renderer to use for rendering. void TitleScreen::Render(GRAPHICS::Renderer& renderer) const { // DRAW THE SUB-HEADING FOR THE GAME'S TITLE. // It is centered within the top third of the screen. MATH::FloatRectangle screen_rectangle = renderer.Screen.GetBoundingRectangle<float>(); float screen_left_x_position = screen_rectangle.GetLeftXPosition(); float screen_top_y_position = screen_rectangle.GetTopYPosition(); float screen_width_in_pixels = screen_rectangle.GetWidth(); float screen_height_in_pixels = screen_rectangle.GetHeight(); float one_third_of_screen_height_in_pixels = screen_height_in_pixels / 3.0f; MATH::FloatRectangle sub_heading_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, screen_top_y_position, screen_width_in_pixels, one_third_of_screen_height_in_pixels); const float BIBLE_GAMES_HEADING_TEXT_SCALE = 1.5f; renderer.RenderCenteredText( "BIBLE GAMES", sub_heading_screen_rectangle, GRAPHICS::Color::WHITE, BIBLE_GAMES_HEADING_TEXT_SCALE); // DRAW THE MAIN GAME'S TITLE. // It is centered within the middle third of the screen. MATH::FloatRectangle main_title_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, one_third_of_screen_height_in_pixels, screen_width_in_pixels, one_third_of_screen_height_in_pixels); const float TITLE_TEXT_SCALE = 3.0f; renderer.RenderCenteredText( "NOAH's ARK", main_title_screen_rectangle, GRAPHICS::Color::YELLOW, TITLE_TEXT_SCALE); // DRAW THE 'PRESS START' TEXT. // It is centered within the bottom third of the screen. float two_thirds_screen_height_in_pixels = 2 * one_third_of_screen_height_in_pixels; MATH::FloatRectangle press_enter_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, two_thirds_screen_height_in_pixels, screen_width_in_pixels, one_third_of_screen_height_in_pixels); renderer.RenderCenteredText( "PRESS ENTER", press_enter_screen_rectangle, GRAPHICS::Color::RED); }
/// Renders the credits screen. /// @param[in,out] renderer - The renderer to use for rendering. void CreditsScreen::Render(GRAPHICS::Renderer& renderer) const { // CALCULATE THE OFFSET OF THE TOP OF THE CREDITS BASED ON THE ELAPSED TIME. // This helps implement scrolling of the credits text upward. const float SCROLL_RATE_IN_PIXELS_PER_SECOND = -4.0f; float elapsed_time_in_seconds = ElapsedTime.asSeconds(); float credits_text_top_offset_in_pixels = SCROLL_RATE_IN_PIXELS_PER_SECOND * elapsed_time_in_seconds; // RENDER TEXT INDICATING THE PURPOSE OF THIS SCREEN. const GRAPHICS::Color CREDITS_TEXT_COLOR = GRAPHICS::Color::WHITE; MATH::FloatRectangle screen_rectangle = renderer.Screen->GetBoundingRectangle<float>(); float screen_left_x_position = screen_rectangle.GetLeftXPosition(); float screen_top_y_position = screen_rectangle.GetTopYPosition(); float screen_width_in_pixels = screen_rectangle.GetWidth(); float screen_height_in_pixels = screen_rectangle.GetHeight(); const float SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS = static_cast<float>(GRAPHICS::GUI::Glyph::DEFAULT_HEIGHT_IN_PIXELS); float credits_text_start_top_y_position = screen_top_y_position + credits_text_top_offset_in_pixels; MATH::FloatRectangle credits_title_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, credits_text_start_top_y_position, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( "CREDITS", RESOURCES::AssetId::FONT_TEXTURE, credits_title_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER TEXT CREDITING GOD. const std::string GOD_CREDIT_TEXT = R"(Him by whom "all things were created" and "all things consist" - from Colossians 1:16-17 (KJV))"; // Some additional spacing is added to help offset this credit text from previous text. float start_of_credits_top_y_position_in_pixels = 2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS + credits_text_start_top_y_position; // This text takes multiple lines to render using the current font. const unsigned int GOD_CREDIT_TEXT_LINE_COUNT = 4; const float GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS = static_cast<float>(GOD_CREDIT_TEXT_LINE_COUNT * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); MATH::FloatRectangle current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, start_of_credits_top_y_position_in_pixels, screen_width_in_pixels, GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( GOD_CREDIT_TEXT, RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR INDIVIDUAL PEOPLE. // Some additional spacing is added to help offset this credit text from other text. const float SPACING_BEFORE_REMAINING_CREDITS = (2 * SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); float current_credits_text_top_y_position_in_pixels = start_of_credits_top_y_position_in_pixels + GOD_CREDIT_TEXT_HEIGHT_IN_PIXELS + SPACING_BEFORE_REMAINING_CREDITS; current_credit_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, current_credits_text_top_y_position_in_pixels, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); renderer.RenderCenteredText( "Programming - Jacob Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); const MATH::Vector2f MOVE_DOWN_SINGLE_LINE(0, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Graphics - Jacob Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Music - Chad Pike", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR SOUND EFFECTS. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "ANIMAL SOUNDS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "soundbible.com", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "BuffBill84", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Mike Koenig", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "snottyboy", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "NPS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "fws.gov", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "BlastwaveFx.com", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Daniel Simion", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Caroline Ford", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "JimBob", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "J Dawg", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "wrzesien", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR DEVELOPMENT TOOLS. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "DEVELOPMENT TOOLS", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Visual Studio 2017", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Git/GitHub", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Microsoft Paint", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Bfxr", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Doxygen", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "SFML", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "Catch", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER ADDITIONAL CREDITS FOR OTHER RESOURCES. current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "OTHER RESOURCES", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); current_credit_text_screen_rectangle.Move(MOVE_DOWN_SINGLE_LINE); renderer.RenderCenteredText( "KJV Bible", RESOURCES::AssetId::FONT_TEXTURE, current_credit_text_screen_rectangle, CREDITS_TEXT_COLOR); // RENDER SOME HELP TEXT TO INFORM PLAYERS HOW TO RETURN TO THE TITLE SCREEN. const float SCREEN_Y_POSITION_ONE_LINE_BEFORE_BOTTOM = screen_height_in_pixels - SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS; MATH::FloatRectangle help_text_screen_rectangle = MATH::FloatRectangle::FromLeftTopAndDimensions( screen_left_x_position, SCREEN_Y_POSITION_ONE_LINE_BEFORE_BOTTOM, screen_width_in_pixels, SINGLE_TEXT_LINE_HEIGHT_IN_PIXELS); // A black rectangle is rendered behind the text to avoid having the text overlap // with other text from the credits and make things hard to read. renderer.RenderScreenRectangle(help_text_screen_rectangle, GRAPHICS::Color::BLACK); renderer.RenderText( "[ESC] to title", RESOURCES::AssetId::FONT_TEXTURE, help_text_screen_rectangle, CREDITS_TEXT_COLOR); }