mirror of
https://github.com/dylanbenzi/pacmen-sfml.git
synced 2026-11-27 00:17:01 +00:00
add inital pacman position
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,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; }
|
||||
|
||||
Reference in New Issue
Block a user