From cc0a4412a4ac7f1f78ef7e644a0c06c6dd6dd129 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 26 Aug 2008 17:42:30 +0000 Subject: improved dust rendering --- src/client/view.cc | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'src/client') diff --git a/src/client/view.cc b/src/client/view.cc index 24cd72e..a737988 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -408,6 +408,14 @@ void draw_status() Text::draw(4, video::height - Text::fontheight()*3-4, statestr); } + core::Entity *target = targets::current(); + float d = 0; + std::stringstream strdistance; + + if (target) { + d = math::distance(core::localcontrol()->location(), target->state()->location()) - target->radius() - core::localcontrol()->radius(); + } + if (draw_devinfo->value()) { std::stringstream devinfo; devinfo << std::fixed << std::setprecision(2) @@ -417,24 +425,28 @@ void draw_status() devinfo << "^Nthurst:^B " << core::localcontrol()->thrust() << " " << "^Nspeed:^B " << core::localcontrol()->speed() << '\n'; + if (target) + devinfo << "^Ndist:^B " << d << '\n'; Text::draw(4, 4 + Text::fontheight(), devinfo); } float y = 1.0f; - core::Entity *entity = targets::current(); - if (entity) { - std::stringstream target; - target << "^B" << entity->name() << "\n"; - target << "^Ndist ^B"; - - math::Vector3f v = entity->state()->location() - core::localcontrol()->state()->location(); - float d = v.length() - entity->radius() - core::localcontrol()->radius(); - if (d > 0 ) - target << std::fixed << std::setprecision(2) << std::setfill(' ') << std::setw(8) << d; - else - target << " --"; - - Text::draw(video::width - 4-Text::fontwidth()*32, video::height - Text::fontheight()*2 -4, target); + if (target) { + std::stringstream strtarget; + strtarget << "^B" << target->name() << "\n^B"; + + if (d > 0 ) { + strtarget << "^Ndist:^B "; + if (d > 100.0f) { + strtarget << roundf(d * 0.1f) << "km"; + } else { + strtarget << roundf(d * 100.0f) << "m"; + } + } else { + strtarget << " --"; + } + strtarget << '\n'; + Text::draw(video::width - 4-Text::fontwidth()*32, video::height - Text::fontheight()*2 -4, strtarget); y = 3.0f; } @@ -460,6 +472,10 @@ void draw_status() gl::end(); float u = core::localcontrol()->thrust(); + if (core::localcontrol()->eventstate() == core::Entity::Impulse) { + u = 1.0; + } + if (( u > 0) || (core::localcontrol()->eventstate() == core::Entity::Impulse)) { if (core::localcontrol()->eventstate() == core::Entity::Impulse) { -- cgit v1.2.3