24 lines
643 B
C++
24 lines
643 B
C++
#pragma once
|
|
#include <iostream>
|
|
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_image.h>
|
|
|
|
class Sprite {
|
|
private:
|
|
SDL_Surface* surface = nullptr;
|
|
SDL_Texture* texture = nullptr;
|
|
float posX = 0.0f;
|
|
float posY = 0.0f;
|
|
public:
|
|
Sprite() = default;
|
|
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; }
|
|
};
|