nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
combat_text.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_COMBAT_TEXT_H_
2#define NANOMMO_CLIENT_COMBAT_TEXT_H_
3
4#include <raylib.h>
5
6#include <cstdint>
7#include <string>
8#include <vector>
9
10#include "client/animator.h"
11#include "protocol/nanommo.pb.h"
12
13namespace nanommo {
14
15/// A number or a line that rises over a unit as something happens to it, such
16/// as the damage of a hit, and fades.
17struct Popup {
18 std::string text;
19 /// The unit it rises over, by its id: a monster's, or else a player's.
20 uint32_t unit = 0;
21 bool monster = false;
22 Color color = WHITE;
23 /// What's about you is bigger than what's about the others.
24 float scale = 1.0f;
25 /// In seconds, since it came.
26 float age = 0.0f;
27};
28
29/// What the events show, kept apart from the drawing, so that it can be
30/// tested without a window.
32 public:
33 /// In seconds.
34 static constexpr float kLife = 1.5f;
35
36 /// Adds what the event shows, to the player whose id is you.
37 void Add(const protocol::Event& event, uint32_t you);
38
39 /// Ages each by the frame's time, and drops the ones past their life.
40 void Update(float seconds);
41
42 const std::vector<Popup>& popups() const { return popups_; }
43
44 private:
45 std::vector<Popup> popups_;
46};
47
48/// Draws each over the figure it's about, rising and fading as it ages.
49void DrawCombatText(const CombatText& text, const std::vector<Figure>& figures,
50 const Camera3D& camera);
51
52} // namespace nanommo
53
54#endif // NANOMMO_CLIENT_COMBAT_TEXT_H_
const std::vector< Popup > & popups() const
Definition combat_text.h:42
static constexpr float kLife
In seconds.
Definition combat_text.h:34
void Add(const protocol::Event &event, uint32_t you)
Adds what the event shows, to the player whose id is you.
void Update(float seconds)
Ages each by the frame's time, and drops the ones past their life.
Definition chat.cc:9
void DrawCombatText(const CombatText &text, const std::vector< Figure > &figures, const Camera3D &camera)
Draws each over the figure it's about, rising and fading as it ages.
float scale
What's about you is bigger than what's about the others.
Definition combat_text.h:24
uint32_t unit
The unit it rises over, by its id: a monster's, or else a player's.
Definition combat_text.h:20
float age
In seconds, since it came.
Definition combat_text.h:26
std::string text
Definition combat_text.h:18