Isolating SFML to the Canvas class.

This commit is contained in:
Ólafur Waage 2021-09-06 15:38:40 +02:00
parent aa22b91e8b
commit fe32b18d0c
4 changed files with 6 additions and 10 deletions

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <SFML/Graphics.hpp>
#include "Direction.hpp" #include "Direction.hpp"
#include "Position.hpp" #include "Position.hpp"
#include <array> #include <array>

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <SFML/Graphics.hpp>
#include "GameState.hpp" #include "GameState.hpp"
#include "Position.hpp" #include "Position.hpp"
#include "Score.hpp" #include "Score.hpp"
@ -7,6 +9,9 @@
namespace pacman { namespace pacman {
using Rect = sf::Rect<int>;
using Sprite = sf::Sprite;
class Canvas { class Canvas {
public: public:
Canvas(); Canvas();

View file

@ -1,8 +1,8 @@
#pragma once #pragma once
#include "Canvas.hpp"
#include "GameState.hpp" #include "GameState.hpp"
#include "InputState.hpp" #include "InputState.hpp"
#include "Canvas.hpp"
namespace pacman { namespace pacman {

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <SFML/Graphics.hpp>
#include <cmath> #include <cmath>
namespace pacman { namespace pacman {
@ -16,10 +15,6 @@ struct GridPosition {
constexpr GridPosition(size_t x, size_t y) : x(x), y(y) {} constexpr GridPosition(size_t x, size_t y) : x(x), y(y) {}
}; };
using Rect = sf::Rect<int>;
using Sprite = sf::Sprite;
inline GridPosition positionToGridPosition(Position pos) { inline GridPosition positionToGridPosition(Position pos) {
return { size_t(std::round(pos.x)), size_t(std::round(pos.y)) }; return { size_t(std::round(pos.x)), size_t(std::round(pos.y)) };
} }
@ -44,6 +39,4 @@ constexpr bool operator!=(const Position & a, const Position & b) {
return !(a == b); return !(a == b);
} }
} // namespace pacman } // namespace pacman