Add fly animations

This commit is contained in:
Bram Verhulst
2024-05-29 00:00:29 +02:00
parent 3c83e566dd
commit e1165fdcb4
31 changed files with 580 additions and 157 deletions

View File

@@ -6,8 +6,7 @@
class Camera;
enum class GroundTileTypes
{
enum class GroundTileTypes {
Air,
Dirt,
Grass,
@@ -38,64 +37,67 @@ static std::map<GroundTileTypes, std::string> GroundTileTypeStrings {
GroundTileType * getRandomGroundTile();
class GroundTileType
{
class GroundTileType {
public:
GroundTileType(const std::string&& filePath, GroundTileTypes type): m_filePath(filePath), m_type(type) {
GroundTileType(const std::string&& filePath, GroundTileTypes type, int value): m_FilePath(filePath), m_Type(type), m_Value(value) {
}
virtual ~GroundTileType() = default;
bool operator==(const GroundTileType& rhs) const {
return m_type == rhs.m_type;
return m_Type == rhs.m_Type;
}
bool operator!=(const GroundTileType& rhs) const {
return m_type != rhs.m_type;
return m_Type != rhs.m_Type;
}
virtual bool operator==(const GroundTileType* rhs) const {
return rhs->m_type == m_type;
return rhs->m_Type == m_Type;
}
virtual bool operator!=(const GroundTileType* rhs) const {
return rhs->m_type != m_type;
return rhs->m_Type != m_Type;
}
virtual std::string getPath() const {
return m_filePath;
virtual std::string GetPath() const {
return m_FilePath;
}
virtual GroundTileTypes getType() const {
return m_type;
virtual GroundTileTypes GetType() const {
return m_Type;
}
virtual int GetValue() const {
return m_Value;
}
protected:
std::string m_filePath;
std::string m_FilePath;
private:
GroundTileTypes m_type;
GroundTileTypes m_Type;
int m_Value;
};
class RandomGroundTile : public GroundTileType
{
class RandomGroundTile : public GroundTileType {
public:
RandomGroundTile(const std::string& filePath, GroundTileTypes type, int maxRandom): GroundTileType(std::move(filePath), type), m_maxRandom(maxRandom) {
RandomGroundTile(const std::string& filePath, GroundTileTypes type, int maxRandom, int value): GroundTileType(std::move(filePath), type, value), m_maxRandom(maxRandom) {
}
~RandomGroundTile() override = default;
bool operator==(const GroundTileType* rhs) const override {
return rhs->getType() == this->getType();
return rhs->GetType() == this->GetType();
}
bool operator!=(const GroundTileType* rhs) const override {
return rhs->getType() != this->getType();
return rhs->GetType() != this->GetType();
}
std::string getPath() const override {
std::string GetPath() const override {
int variant = utils::randRange(1, m_maxRandom);
std::string toReplace { "[0]" };
std::string replacement = std::to_string(utils::randRange(1, m_maxRandom));
size_t found = m_filePath.find(toReplace);
std::string newFilePath { m_filePath };
size_t found = m_FilePath.find(toReplace);
std::string newFilePath { m_FilePath };
if (found != std::string::npos) {
newFilePath.replace(found, 3, replacement);
@@ -108,10 +110,9 @@ private:
int m_maxRandom;
};
class Tiles
{
class Tiles {
public:
};
// static std::map<GroundTileType *, float> GroundTileWeights {
@@ -128,12 +129,11 @@ public:
// { Tiles::Ores::IRON, 0.1f },
// };
static std::map<GroundTileType*, float> GroundTileWeights;
static std::map<GroundTileType *, float> GroundTileWeights;
void InitializeGroundTiles();
class WorldTile
{
class WorldTile {
public:
WorldTile() = default;
WorldTile(const Vector2f& position, GroundTileType* groundTileType, TextureManager* pTextureManager, WorldGridManager* pGridManager);
@@ -158,7 +158,7 @@ public:
}
void SetTileType(GroundTileType* type) {
m_GroundTileType = type;
m_pTexture = TextureManager::GetInstance()->GetTexture(type->getPath()); //Chage the texture when setting a new type
m_pTexture = TextureManager::GetInstance()->GetTexture(type->GetPath()); //Chage the texture when setting a new type
}
Collision::TileCollisionRect GetCollisionRect();
@@ -179,7 +179,7 @@ private:
surroundingTiles m_SurroundingTiles;
std::vector<Texture*> m_SideTextures { 8, nullptr };
std::vector<Texture *> m_SideTextures { 8, nullptr };
Texture* m_pAllTexture;
};