I'm thinking something as simple as:
float dis=0;
onTick(){
if(upkey.ispresssed) || downkey.ispressed){ if(upkey.ispressed && downkey.ispressed) { } else{ dis+= walkspeed/ticksPerSec;
if(leftkey.ispresssed) || rightkey.ispressed){ if(leftkey.ispressed && rightkey.ispressed) { } else{ dis+= walkspeed/ticksPerSec;
}
void clear(){
dis=0;
}
void read(){
cout<<dis;
}
Simple. Quick. Done.
I was thinking about pedometer. You got me confused for a sec :p
+1
(http://www.opticraft.net/proxy.php?request=http%3A%2F%2Ffc00.deviantart.net%2Ffs37%2Fi%2F2008%2F245%2F7%2Fe%2FPedobear_Vector_by_kb1.png&hash=815553d15ce4de28047d97c38b8d025a)
step 1 press F3
step 2 remember your coords
step 3 walk
step 4 check coords
step 5 substract bingo?
My only problem with this is that it can't realistically measure curved paths, paths that backtrack, or paths that move along more than one axis. the pedometer output could output something like:
total distance: 100m [x:45m, y:50m, z:5m]
...which would be nice, because then you could ignore drops in height, measure drops in height as you descend stairs, you could measure backtrack and curves, etc. all with one tool.