Win Canvas
You Won
The WinCanvas becomes visible when the Player wins. To ensure it always fits the screen and remains centered, its size is updated every frame to match the window dimensions, and its position is recalculated to be in the center of the window on each frame. This allows it to respond dynamically to any window resizing.
#pragma once
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Text.hpp>
#include "engine/node.h"
namespace game {
class WinCanvas : public ng::Node {
public:
explicit WinCanvas(ng::App* app);
void Enable();
void Disable();
protected:
void Draw(sf::RenderTarget& target) override;
private:
bool is_enabled_ = false;
sf::RectangleShape background_;
sf::Text title_text_;
sf::Text restart_text_;
};
} // namespace gameLast updated