-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurretButton.cpp
More file actions
28 lines (26 loc) · 854 Bytes
/
TurretButton.cpp
File metadata and controls
28 lines (26 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <allegro5/color.h>
#include "GameEngine.hpp"
#include "IScene.hpp"
#include "PlayScene.hpp"
#include "TurretButton.hpp"
PlayScene* TurretButton::getPlayScene() {
return dynamic_cast<PlayScene*>(Engine::GameEngine::GetInstance().GetActiveScene());
}
TurretButton::TurretButton(std::string img, std::string imgIn, Engine::Sprite Base, Engine::Sprite Turret, float x, float y, int money) :
ImageButton(img, imgIn, x, y), money(money), Base(Base), Turret(Turret) {
}
void TurretButton::Update(float deltaTime) {
ImageButton::Update(deltaTime);
if (getPlayScene()->GetMoney() >= money) {
Enabled = true;
Base.Tint = Turret.Tint = al_map_rgba(255, 255, 255, 255);
} else {
Enabled = false;
Base.Tint = Turret.Tint = al_map_rgba(0, 0, 0, 160);
}
}
void TurretButton::Draw() const {
ImageButton::Draw();
Base.Draw();
Turret.Draw();
}