diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/game.cpp | 25 | ||||
-rw-r--r-- | src/game/interface.cpp | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 8deadd6..4b9a9a3 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -251,6 +251,31 @@ void state_t::command(v2f_t x, int number) if (!selected_units.size()) return; + // debugging + if (number == 666) { + for (size_t i = 0; i < 100; i++) { + v2f_t rad; + world::trace_t best; + + best.hit = false; + best.frac = 2.0f; + + rad = v2f_t::rad(i / 99.0f * 2.0f * M_PI); + + for (unit_t *unit : selected_units) { + world::trace_t trace; + + trace = world::ray_v_rect(x, x + rad * 10, unit->cmodel.bounds); + if (trace.frac < best.frac) + best = trace; + } + + debug_render->render_line(x, best.end, (best.hit ? sf::Color::Yellow : sf::Color::White)); + } + + return; + } + snap[0] = std::round(x[0] - 0.5f) + 0.5f; snap[1] = std::round(x[1] - 0.5f) + 0.5f; diff --git a/src/game/interface.cpp b/src/game/interface.cpp index b187d42..7615acf 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -334,6 +334,12 @@ void state_t::render_to(render::state_t *render) std::stringstream ss; double fps; + // debug + { + auto wmouse = window->mapPixelToCoords(sf::Mouse::getPosition(*window)); + game->command(wmouse, 666); + } + if (select.selecting) { sf::Color color; |