Peoplemon  0.1.0
Peoplemon 3 game source documentation
PeoplemonAnimation.hpp
Go to the documentation of this file.
1 #ifndef CORE_BATTLES_VIEW_PEOPLEMONANIMATION_HPP
2 #define CORE_BATTLES_VIEW_PEOPLEMONANIMATION_HPP
3 
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Particles/System.hpp>
6 #include <BLIB/Render/Scenes/CodeScene.hpp>
7 #include <BLIB/Resources.hpp>
11 
12 namespace core
13 {
14 namespace battle
15 {
16 namespace view
17 {
24 public:
29 
36  PeoplemonAnimation(bl::engine::Engine& engine, Position position);
37 
42 
48  void init(bl::rc::scene::CodeScene* scene);
49 
55  void setPeoplemon(pplmn::Id ppl);
56 
62  void triggerAnimation(const cmd::Animation& anim);
63 
70 
74  bool completed() const;
75 
81  void update(float dt);
82 
88  void render(bl::rc::scene::CodeScene::RenderContext& ctx);
89 
90 private:
91  enum struct State { Hidden, Static, Playing };
92 
93  bl::engine::Engine& engine;
94  bl::rc::scene::CodeScene* scene;
95  const Position position;
96  const VkViewport viewport;
97  const VkRect2D scissor;
98  State state;
100  union {
101  float slideAmount;
102  float alpha;
103  float shakeTime;
104  float ballTime;
105  float arrowTime;
106  float throwX;
107  float bounceTime;
108  };
109  glm::vec2 shakeOff;
110 
111  bl::rc::res::TextureRef ballTxtr;
112  bl::rc::res::TextureRef ballOpenTxtr;
113  bl::gfx::Sprite ball;
114  bl::gfx::Circle ballFlash;
115 
116  bl::pcl::ParticleManager<PeoplemonSpark>* sparks;
117  SparkExplosionEmitter* sparkExplosionEmitter;
118  bl::pcl::ParticleManager<PeoplemonSpark>* implosion;
119  SparkImplosionEmitter* sparkImplosionEmitter;
120  bl::gfx::Rectangle screenFlash;
121 
122  bl::rc::res::TextureRef statTxtr;
123  bl::gfx::Sprite statArrow;
124  float arrowOffset;
125  bool renderBall;
126 
127  enum struct BallThrowState { Arcing, Eating, Bouncing, CloneFading } throwState;
128  bl::rc::res::TextureRef throwBallTxtr;
129  bl::gfx::Sprite throwBall;
130  bl::gfx::Sprite clone;
131  bl::gfx::Sprite* toEat;
132 
133  void setBallTexture(bl::rc::res::TextureRef& t);
134  void setThrowBallTxtr(bl::rc::res::TextureRef& t);
135 
136  bl::resource::Ref<bl::gfx::a2d::AnimationData> annoySrc;
137  bl::resource::Ref<bl::gfx::a2d::AnimationData> confuseSrc;
138  bl::resource::Ref<bl::gfx::a2d::AnimationData> frozenSrc;
139  bl::resource::Ref<bl::gfx::a2d::AnimationData> frustrationSrc;
140  bl::resource::Ref<bl::gfx::a2d::AnimationData> sleepSrc;
141  bl::resource::Ref<bl::gfx::a2d::AnimationData> stickySrc;
142  bl::resource::Ref<bl::gfx::a2d::AnimationData> trappedSrc;
143  bl::resource::Ref<bl::gfx::a2d::AnimationData> jumpedSrc;
144  bl::gfx::Animation2D ailmentAnim;
145 
146  void updateAilmentAnimation(pplmn::Ailment ail);
147  void updateAilmentAnimation(pplmn::PassiveAilment ail);
148  void recreateAilmentAnimation(bl::resource::Ref<bl::gfx::a2d::AnimationData>& src);
149 
150  bl::rc::res::TextureRef txtr;
151  bl::gfx::Sprite peoplemon;
152  glm::vec2 scale;
153 };
154 
155 } // namespace view
156 } // namespace battle
157 } // namespace core
158 
159 #endif
PassiveAilment
Represents a passive ailment a Peoplemon can have.
Ailment
Represents an ailment that a Peoplemon can have.
Definition: Ailment.hpp:16
Id
The id of a peoplemon.
Definition: Id.hpp:16
Core classes and functionality for both the editor and game.
Represents a type of animation that can be played in battle.
Definition: Animation.hpp:25
Type
The type of animation to play.
Definition: Animation.hpp:30
Helper for rendering peoplemon in battle and animating them.
void init(bl::rc::scene::CodeScene *scene)
Initializes rendering resources.
Position
Which position the peoplemon is in.
PeoplemonAnimation(bl::engine::Engine &engine, Position position)
Construct a new Peoplemon Animation utility.
void triggerAnimation(cmd::Animation::Type type)
Begins playing the given animation by type only.
void render(bl::rc::scene::CodeScene::RenderContext &ctx)
Renders the peoplemon animation.
void triggerAnimation(const cmd::Animation &anim)
Begins playing the given animation.
bool completed() const
Returns true if the animation has completed, false if in progress.
void update(float dt)
Updates the playing animation.
void setPeoplemon(pplmn::Id ppl)
Sets the specific peoplemon graphic and resets to hidden state.
Particle system spark emitter for explosions.
Particle system spark emitter for implosions.