add inital pacman position

This commit is contained in:
2025-11-10 11:36:20 -05:00
parent a58c19817c
commit 36bbf5b888
3 changed files with 15 additions and 0 deletions
+2
View File
@@ -69,6 +69,8 @@ void Game::run() {
pacman.setAnimationTiles(resources.getTexture("all_textures"), {1952, 0}, "static", {60, 60}, 1, 0);
pacman.setAnimationTiles(resources.getTexture("all_textures"), {2016, 0}, "death", {60, 60}, 11, 4);
pacman.setActiveSprite("static", 0);
pacman.setOrigin({30, 30});
pacman.setPosition({32 * 14.5 - 16, 32 * 24 - 16});
blinky.setAnimationTiles(resources.getTexture("all_textures"), {1824, 256}, "right_walking", {60, 60}, 2, 4);
blinky.setAnimationTiles(resources.getTexture("all_textures"), {1952, 256}, "left_walking", {60, 60}, 2, 4);
+10
View File
@@ -1,4 +1,5 @@
#include "MazeMap.h"
#include <SFML/System/Vector2.hpp>
bool MazeMap::loadMaze(const std::vector<int>& collisionData,
const std::vector<int>& pelletData,
@@ -102,3 +103,12 @@ void MazeMap::draw(sf::RenderTarget& target, sf::RenderStates states) const {
target.draw(pelletVertices, states);
}
// assumes maze is drawn at 0,0
sf::Vector2i MazeMap::getTileCoords(sf::Vector2f screenPos) {
int tileX = static_cast<int>(screenPos.x / tileSize);
int tileY = static_cast<int>(screenPos.y / tileSize);
return {tileX, tileY};
};
+3
View File
@@ -3,6 +3,7 @@
#include <SFML/Graphics.hpp>
#include <SFML/System/Vector2.hpp>
#include <vector>
#include <filesystem>
@@ -26,6 +27,8 @@ public:
int convert2DCoords(int x, int y) const { return x + y * width; }
bool isLegalTile(int x, int y) const;
sf::Vector2i getTileCoords(sf::Vector2f screenPos);
unsigned int getWidth() const { return width; }
unsigned int getHeight() const { return height; }
unsigned int getTileSize() const { return tileSize; }