-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpac.inl
60 lines (47 loc) · 1.53 KB
/
pac.inl
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "pac.h"
using namespace kabuki::arcade;
Pac::Pac(sf::Texture& texture)
: is_dead_(false), is_dying_(false), visual_(texture) {
setOrigin(20, 20);
// run_animator_.AddFrame(sf::IntRect(0, 32, 40, 40));
run_animator_.AddFrame(sf::IntRect(0, 72, 40, 40));
// die_animator_.AddFrame(sf::IntRect(0, 32, 40, 40));
// die_animator_.AddFrame(sf::IntRect(0, 72, 40, 40));
// die_animator_.AddFrame(sf::IntRect(0, 112, 40, 40));
// die_animator_.AddFrame(sf::IntRect(40, 112, 40, 40));
// die_animator_.AddFrame(sf::IntRect(80, 112, 40, 40));
// die_animator_.AddFrame(sf::IntRect(120, 112, 40, 40));
// die_animator_.AddFrame(sf::IntRect(160, 112, 40, 40));
run_animator_.Play(sf::seconds(0.25), true);
}
void Pac::Die() {
if (!is_dying_) {
die_animator_.Play(sf::seconds(1), false);
is_dying_ = true;
}
}
void Pac::Reset() {
is_dying_ = false;
is_dead_ = false;
run_animator_.Play(sf::seconds(0.25), true);
run_animator_.Animate(visual_);
}
bool Pac::IsDying() { return is_dying_; }
bool Pac::IsDead() { return is_dead_; }
void Pac::draw(sf::RenderTarget& target, sf::RenderStates states) const {
states.transform *= getTransform();
if (!is_dead_) target.draw(visual_, states);
}
void Pac::Update(sf::Time delta) {
if (!is_dead_ && !is_dying_) {
run_animator_.Update(delta);
run_animator_.animate_visual_);
} else {
// die_animator_.Update(delta);
die_animator.Animate(visual_);
if (!die_animator_.IsPlaying()) {
is_dying _ = false;
is_dead_ = true;
}
}
}