summaryrefslogtreecommitdiff
path: root/src/game/decos.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/decos.cpp')
-rw-r--r--src/game/decos.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/game/decos.cpp b/src/game/decos.cpp
new file mode 100644
index 0000000..2307762
--- /dev/null
+++ b/src/game/decos.cpp
@@ -0,0 +1,56 @@
+#include "game.hpp"
+
+namespace game {
+
+static const struct {
+ render::animated_texture_t *texture;
+ v2f_t mins, maxs;
+ world::cflags_t cflags;
+ v2f_t render_mins, render_maxs;
+ double fps;
+} decos[ ] = {
+ {
+ &assets::deco.stone,
+ {-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID,
+ {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0
+ },
+ {
+ &assets::deco.stone,
+ {-0.2f, +0.1f}, {+0.2f, +0.2f}, CF_SOLID,
+ {-0.2f, -0.2f}, {+0.2f, +0.2f}, 0.0
+ },
+ {
+ &assets::deco.eyething,
+ {-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID,
+ {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3
+ }
+};
+
+deco_t::deco_t(game::state_t *game_, deco_type_t type_) : entity_t(ET_DECO)
+{
+ game = game_;
+ type = type_;
+}
+
+void deco_t::spawn(world::world_t *world, v2f_t x)
+{
+ v2f_t center, offset;
+
+ offset[0] = world->perlin.get(x, 0.17331f);
+ offset[1] = world->perlin.get(x, 0.19571f);
+ center = x + v2f_t(0.5f, 0.5f) + offset.norm() * 0.1;
+
+ cmodel.bounds[0] = center + decos[type].mins;
+ cmodel.bounds[1] = center + decos[type].maxs;
+ cmodel.cflags = decos[type].cflags;
+ render_bounds[0] = center + decos[type].render_mins;
+ render_bounds[1] = center + decos[type].render_maxs;
+ link(world);
+}
+void deco_t::render_to(render::state_t *render)
+{
+ render->render(game->now * decos[type].fps + phase_shift,
+ decos[type].texture, render_bounds, sf::Color::White);
+}
+
+} // namespace game