mirror of
https://github.com/dylanbenzi/pacmen-sfml.git
synced 2026-11-27 08:26:59 +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"), {1952, 0}, "static", {60, 60}, 1, 0);
|
||||||
pacman.setAnimationTiles(resources.getTexture("all_textures"), {2016, 0}, "death", {60, 60}, 11, 4);
|
pacman.setAnimationTiles(resources.getTexture("all_textures"), {2016, 0}, "death", {60, 60}, 11, 4);
|
||||||
pacman.setActiveSprite("static", 0);
|
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"), {1824, 256}, "right_walking", {60, 60}, 2, 4);
|
||||||
blinky.setAnimationTiles(resources.getTexture("all_textures"), {1952, 256}, "left_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 "MazeMap.h"
|
||||||
|
#include <SFML/System/Vector2.hpp>
|
||||||
|
|
||||||
bool MazeMap::loadMaze(const std::vector<int>& collisionData,
|
bool MazeMap::loadMaze(const std::vector<int>& collisionData,
|
||||||
const std::vector<int>& pelletData,
|
const std::vector<int>& pelletData,
|
||||||
@@ -102,3 +103,12 @@ void MazeMap::draw(sf::RenderTarget& target, sf::RenderStates states) const {
|
|||||||
|
|
||||||
target.draw(pelletVertices, states);
|
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/Graphics.hpp>
|
||||||
|
|
||||||
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
@@ -26,6 +27,8 @@ public:
|
|||||||
int convert2DCoords(int x, int y) const { return x + y * width; }
|
int convert2DCoords(int x, int y) const { return x + y * width; }
|
||||||
bool isLegalTile(int x, int y) const;
|
bool isLegalTile(int x, int y) const;
|
||||||
|
|
||||||
|
sf::Vector2i getTileCoords(sf::Vector2f screenPos);
|
||||||
|
|
||||||
unsigned int getWidth() const { return width; }
|
unsigned int getWidth() const { return width; }
|
||||||
unsigned int getHeight() const { return height; }
|
unsigned int getHeight() const { return height; }
|
||||||
unsigned int getTileSize() const { return tileSize; }
|
unsigned int getTileSize() const { return tileSize; }
|
||||||
|
|||||||
Reference in New Issue
Block a user