aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2014-12-01 21:23:00 +1000
committerAlec Thomas <alec@swapoff.org>2014-12-01 21:23:00 +1000
commit8428872738e6819abc7c11945bee7acda77144d2 (patch)
tree702ccf6a570036db78f7c36c6db99e3890f17565 /examples
parent9e4314ef1d4575caa99fee3a4ae7f479b8153a34 (diff)
Include cmath in example. Fixes #66.
Diffstat (limited to 'examples')
-rw-r--r--examples/example.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/example.cc b/examples/example.cc
index 582e324..d6385b3 100644
--- a/examples/example.cc
+++ b/examples/example.cc
@@ -15,6 +15,7 @@
*
* c++ -O3 -std=c++11 -Wall -lsfml-system -lsfml-window -lsfml-graphics -lentityx readme.cc -o readme
*/
+#include <cmath>
#include <unordered_set>
#include <sstream>
#include <cstdlib>
@@ -33,10 +34,10 @@ using std::endl;
namespace ex = entityx;
namespace std {
- template <>
- struct hash<ex::Entity> {
- std::size_t operator()(const ex::Entity& k) const { return k.id().id(); }
- };
+template <>
+struct hash<ex::Entity> {
+ std::size_t operator()(const ex::Entity& k) const { return k.id().id(); }
+};
}
@@ -104,9 +105,9 @@ struct FadeOutSystem : public ex::System<FadeOutSystem> {
Renderable::Handle renderable;
for (ex::Entity entity : es.entities_with_components(fade, renderable)) {
fade->alpha -= fade->d * dt;
- if (fade->alpha <= 0)
+ if (fade->alpha <= 0) {
entity.destroy();
- else {
+ } else {
sf::Color color = renderable->shape->getFillColor();
color.a = fade->alpha;
renderable->shape->setFillColor(color);
@@ -153,7 +154,7 @@ class CollisionSystem : public ex::System<CollisionSystem> {
ex::Entity entity;
};
- public:
+public:
explicit CollisionSystem(sf::RenderTarget &target) : size(target.getSize()) {
size.x = size.x / PARTITIONS + 1;
size.y = size.y / PARTITIONS + 1;