Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-26 17:42:30 +0000
committerStijn Buys <ingar@osirion.org>2008-08-26 17:42:30 +0000
commitcc0a4412a4ac7f1f78ef7e644a0c06c6dd6dd129 (patch)
tree27271e45ca42c1039d149ab30637fe4fb08eb732 /src/client/view.cc
parent02e623574c4c12c40a0757ed934a93353f34a653 (diff)
improved dust rendering
Diffstat (limited to 'src/client/view.cc')
-rw-r--r--src/client/view.cc44
1 files changed, 30 insertions, 14 deletions
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) {