pacman/lib/Canvas.hpp
Patricia Aas 68f63f3f66
Canvas rewrite (#6)
* Beginning rewrite

* Move all constants to canvas, wire sprite handling code

* Make Sprite a struct and reformat

* Fix warning

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
2021-06-16 12:52:04 +02:00

34 lines
1 KiB
C++

#pragma once
#include "SDLWindow.hpp"
class PacMan;
class Pellets;
class SuperPellets;
class Canvas {
public:
Canvas();
void update(const PacMan & pacMan, const Pellets & pellets, const SuperPellets & superPellets);
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;
static constexpr float TEXTURE_SCALE_FACTOR = 0.5;
void renderMaze() const;
void renderPacMan(const PacMan & pac_man) const;
void renderPellets(const Pellets & pellets) const;
void renderSuperPellets(const SuperPellets & superPellets) const;
void renderSprite(Sprite sprite, SDL_Point point) const;
SDL_Rect windowDimensions() const;
Sprite getSprite(SDL_Point rect) const;
SDLWindow window;
};