Skip to content

Commit

Permalink
Crater Decal added
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexpop11 committed Nov 5, 2024
1 parent 924d617 commit 5be197d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
Binary file added OpenGL/res/textures/crater-decal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion OpenGL/src/game_objects/Bomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void Bomb::explode() {
}

audio().Bomb_Sound.play();
World::gameobjectstoadd.push_back(std::make_unique<Decal>("ExplosionDecal", getTile().x, getTile().y, "explosion-decal.png"));
World::gameobjectstoadd.push_back(std::make_unique<Decal>("ExplosionDecal", getTile().x, getTile().y, "crater"));
World::gameobjectstoadd.push_back(std::make_unique<Decal>("ExplosionDecal", getTile().x, getTile().y, "explosion"));
ShouldDestroy = true;
}

Expand Down
13 changes: 10 additions & 3 deletions OpenGL/src/game_objects/Decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
#include "AudioEngine.h""
Decal::Decal(const std::string& name, float x, float y, const std::string& type)
: SquareObject(name, DrawPriority::Decal, x, y, type)
: SquareObject(name, DrawPriority::Decal, x, y, chooseTexture(type))
, texturepath(chooseTexture(type)) {
rotation = std::vector<int>{0, 90, 180, 270}[rand() % 4];
scale = std::vector<float>{0.85, 0.9, 0.95, 1, 1.05}[rand() % 5];
if (texturepath == "explosion-decal.png") {
scale = std::vector<float>{0.85, 0.9, 0.95, 1, 1.05}[rand() % 5];
}
else if (texturepath == "crater-decal.png") {
scale = 3;
}
rotation = std::vector<int>{0, 90, 180, 270}[rand() % 4];
tintColor = {0.8, 0.5, 0.5, 0.9};
}
Expand All @@ -27,6 +32,8 @@ Decal::Decal(const std::string& name, float x, float y, const std::string& type)
std::string Decal::chooseTexture(const std::string& type) {
if (type == "explosion") {
return "explosion-decal.png";
} else if (type == "crater") {
return "crater-decal.png";
}
return "enemy.png"; // Fallback path if type doesn't match any condition
}
Expand Down
1 change: 1 addition & 0 deletions OpenGL/src/game_objects/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum class DrawPriority {
Background,
Floor,
Decal,
Wall,
Bomb,
Character,
CharacterAccent,
Expand Down
3 changes: 2 additions & 1 deletion OpenGL/src/game_objects/Tile.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "Tile.h"

Tile::Tile(const std::string& name, bool wall, bool unbreakable, float x, float y)
: SquareObject(name, DrawPriority::Floor, x, y, "alt-wall-bright.png")
: SquareObject(name, wall ? DrawPriority::Wall : DrawPriority::Floor, x, y, "alt-wall-bright.png")
, wall(wall)
, unbreakable(unbreakable)
, wallTexture(Texture::create("alt-wall-bright.png"))
, wallTextureUnbreakable(Texture::create("alt-wall-unbreakable.png"))
, floorTexture(Texture::create(std::vector<std::string>{"2-alt-floor.png", "2-alt-floor-2.png"}[rand() % 2])) {
setTexture();

}

Tile::Tile(const std::string& name, float x, float y)
Expand Down

0 comments on commit 5be197d

Please sign in to comment.