Fixing forward decl issue and conversion error.
This commit is contained in:
parent
c495dd9c37
commit
ed6466a306
2 changed files with 27 additions and 27 deletions
|
@ -101,21 +101,21 @@ void Canvas::renderPacMan(const PacMan & pac_man) {
|
|||
renderSprite(pacmanSprite, pos);
|
||||
}
|
||||
|
||||
void Canvas::renderFruits(const Fruits& fruit, int eatenFruits) {
|
||||
Sprite sprite = getSprite(fruit.currentSprite());
|
||||
if(fruit.isVisible()) {
|
||||
const auto & pos = fruit.position();
|
||||
renderSprite(sprite, pos);
|
||||
}
|
||||
const size_t x = (LEFT_MARGIN + TARGET_MAZE_WIDTH + LEFT_MARGIN);
|
||||
const size_t y = (TARGET_MAZE_HEIGHT / 3.0) * 2;
|
||||
void Canvas::renderFruits(const Fruits & fruit, int eatenFruits) {
|
||||
Sprite sprite = getSprite(fruit.currentSprite());
|
||||
if (fruit.isVisible()) {
|
||||
const auto & pos = fruit.position();
|
||||
renderSprite(sprite, pos);
|
||||
}
|
||||
const size_t x = static_cast<size_t>(LEFT_MARGIN + TARGET_MAZE_WIDTH + LEFT_MARGIN);
|
||||
const size_t y = static_cast<size_t>((TARGET_MAZE_HEIGHT / 3.0) * 2);
|
||||
|
||||
for (auto i = 0; i < eatenFruits + 1; i++) {
|
||||
auto sprite_position = float(i) * SPRITE_WIDTH * 1.5f;
|
||||
sf::Vector2f pos{ x + sprite_position, y };
|
||||
sprite.setPosition(pos.x, pos.y);
|
||||
window.draw(sprite);
|
||||
}
|
||||
for (auto i = 0; i < eatenFruits + 1; i++) {
|
||||
auto sprite_position = float(i) * SPRITE_WIDTH * 1.5f;
|
||||
sf::Vector2f pos{ x + sprite_position, y };
|
||||
sprite.setPosition(pos.x, pos.y);
|
||||
window.draw(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::renderGhost(const Ghost & ghost) {
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
#pragma once
|
||||
#include <chrono>
|
||||
#include "Position.hpp"
|
||||
#include <chrono>
|
||||
|
||||
namespace pacman {
|
||||
|
||||
class GameState;
|
||||
class Fruits {
|
||||
struct GameState;
|
||||
|
||||
class Fruits {
|
||||
public:
|
||||
void update(std::chrono::milliseconds time_delta, const GameState & gameState);
|
||||
GridPosition currentSprite() const;
|
||||
Position position() const;
|
||||
bool isVisible() const;
|
||||
int value() const;
|
||||
int eat();
|
||||
void update(std::chrono::milliseconds time_delta, const GameState & gameState);
|
||||
GridPosition currentSprite() const;
|
||||
Position position() const;
|
||||
bool isVisible() const;
|
||||
int value() const;
|
||||
int eat();
|
||||
|
||||
private:
|
||||
void hide();
|
||||
bool visible = false;
|
||||
int index = 0;
|
||||
std::chrono::milliseconds time_visible{0};
|
||||
void hide();
|
||||
bool visible = false;
|
||||
int index = 0;
|
||||
std::chrono::milliseconds time_visible{ 0 };
|
||||
};
|
||||
|
||||
} // namespace pacman
|
||||
|
|
Loading…
Reference in a new issue