From 9f88509c8e440d9bb3430b71708efd69988f461c Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 2 Dec 2017 12:28:40 +0100 Subject: Tracing rays through the world. --- src/game.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 8daa7d0..fd119f8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -9,6 +9,7 @@ enum { }; class unit_t : public world::entity_t { +protected: world::world_t *world; world::cmodel_t make_cmodel(v2f_t at) @@ -182,6 +183,19 @@ public: render->render(&assets::human.body_idle, render_bounds, move.angle); render->render(&assets::human.head_idle, render_bounds, move.angle); + { + v2f_t x1; + static float t = 0; + world::trace_t trace; + + t += 0.02f; + + x1[0] = x[0] + cos(t) * 5; + x1[1] = x[1] + sin(t) * 5; + trace = world->trace(x, x1, 1); + render->render_arrow(x, trace.end, sf::Color::Green); + } + if (move.moving && debug_draw_paths) render->debug_path(&move.path); @@ -200,13 +214,11 @@ public: void state_t::start(void) { - for (size_t i = 0; i < 10; i++) { - human_t *human; + human_t *human; - human = new human_t; - human->place(&world, v2f_t(0.5, 0.5) + i * v2f_t(0.2, -1.2f)); - units.insert(human); - } + human = new human_t; + human->place(&world, v2f_t(0.5, 0.5)); + units.insert(human); } void state_t::stop(void) -- cgit