2021-06-16 10:52:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
#include "Position.hpp"
|
|
|
|
#include <optional>
|
2021-06-16 10:52:04 +00:00
|
|
|
|
|
|
|
class PacMan;
|
|
|
|
class Pellets;
|
|
|
|
class SuperPellets;
|
|
|
|
|
|
|
|
class Canvas {
|
|
|
|
public:
|
|
|
|
Canvas();
|
|
|
|
void update(const PacMan & pacMan, const Pellets & pellets, const SuperPellets & superPellets);
|
2021-06-20 16:52:34 +00:00
|
|
|
std::optional<sf::Event> pollEvent();
|
2021-06-16 10:52:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr int16_t LEFT_MARGIN = 40;
|
|
|
|
static constexpr int16_t TOP_MARGIN = 40;
|
|
|
|
static constexpr int16_t BOTTOM_MARGIN = 40;
|
|
|
|
static constexpr int16_t MAZE_WIDTH = 448;
|
|
|
|
static constexpr int16_t MAZE_HEIGHT = 496;
|
|
|
|
static constexpr int16_t SCORE_WIDTH = 200;
|
|
|
|
static constexpr int16_t DEFAULT_SPRITE_WIDTH = 32;
|
|
|
|
static constexpr int16_t DEFAULT_SPRITE_HEIGHT = 32;
|
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
void clear();
|
|
|
|
void render();
|
|
|
|
void renderMaze();
|
|
|
|
void renderPacMan(const PacMan & pac_man);
|
|
|
|
void renderPellets(const Pellets & pellets);
|
|
|
|
void renderSuperPellets(const SuperPellets & superPellets);
|
|
|
|
void renderSprite(Sprite sprite, PositionInt point);
|
|
|
|
void renderSprite(Sprite sprite, Rect target);
|
|
|
|
|
2021-06-16 13:18:00 +00:00
|
|
|
void renderScore(int score);
|
2021-06-16 10:52:04 +00:00
|
|
|
|
2021-06-20 16:52:34 +00:00
|
|
|
Rect windowDimensions() const;
|
|
|
|
|
|
|
|
void loadTextures();
|
|
|
|
sf::Texture loadTexture(std::string_view path);
|
|
|
|
sf::Font loadFont(std::string_view path);
|
|
|
|
|
|
|
|
Sprite getSprite(PositionInt rect) const;
|
|
|
|
|
|
|
|
sf::RenderWindow window;
|
|
|
|
sf::Texture maze_texture;
|
|
|
|
sf::Texture sprites_texture;
|
|
|
|
sf::Font game_font;
|
2021-06-16 10:52:04 +00:00
|
|
|
};
|