add base support for entity animation and drawing

This commit is contained in:
2025-11-08 22:53:44 -05:00
parent a2b7d62971
commit 8cebec8684
3 changed files with 66 additions and 50 deletions
+8 -1
View File
@@ -1,15 +1,17 @@
#include <SFML/Graphics/RenderWindow.hpp>
#include <iostream>
#include "Game.h"
#include "MazeMap.h"
#include "ResourceManager.h"
#include "Entity.h"
void Game::run() {
ResourceManager resources;
MazeMap map;
Entity pacman;
resources.loadTexture("all_textures", "assets/all_textures.png");
// resize all_textures to 32px
resources.resizeTexture("all_textures", 32);
// Collision data: 1=wall, 0=path
@@ -27,6 +29,9 @@ void Game::run() {
{912, 0},
{0, 0});
pacman.setAnimationTiles(resources.getTexture("all_textures"), {1820, 0}, "right_walking", {60, 60}, 2, 0);
pacman.setActiveSprite("right_walking", 0);
auto window = sf::RenderWindow(sf::VideoMode(windowRes), windowName);
window.setFramerateLimit(maxFPS);
@@ -44,6 +49,8 @@ void Game::run() {
window.draw(map);
window.draw(*pacman.getActiveSprite());
//window.draw();
window.display();