ajout de Sprite et de TILES
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
#include "Sprite.hpp"
|
||||||
|
|
||||||
|
Sol::Sol() {
|
||||||
|
// Constructor implementation
|
||||||
|
|
||||||
|
std::cout << "Sol created." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sol::~Sol() {
|
||||||
|
// Destructor implementation
|
||||||
|
std::cout << "Sol destroyed." << std::endl;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Sprite.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class Sol: public Sprite {
|
||||||
|
public:
|
||||||
|
Sol();
|
||||||
|
virtual ~Sol();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#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; }
|
||||||
|
};
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user