Files
2025-06-01 10:34:29 +02:00

26 lines
722 B
C++

#pragma once
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <exception>
class Sprite {
private:
SDL_Surface* surface = nullptr;
SDL_Texture* texture = nullptr;
float posX = 0.0f;
float posY = 0.0f;
public:
Sprite() = default;
Sprite(SDL_Renderer* renderer, std::string filePath);
virtual ~Sprite() = default;
// Pure virtual function to be implemented by derived classes
virtual void draw() const = 0;
// Function to set the position of the sprite
virtual void setPosition(float x, float y) { posX = x; posY = y; }
// Function to get the current position of the sprite
virtual void getPosition(float &x, float &y) const { x = posX; y = posY; }
};