10 static int time_diff(
struct timeval x ,
struct timeval y)
12 int x_ms , y_ms , diff;
14 x_ms = x.tv_sec*1000 + x.tv_usec/1000;
15 y_ms = y.tv_sec*1000 + y.tv_usec/1000;
24 std::cout <<
"Creating Bikex" << std::endl;
53 std::cout <<
"Termination Bikex" << std::endl;
68 std::cout <<
"Initiating Bikex" << std::endl;
83 std::cout <<
"Bikex state" << std::endl;
84 std::cout <<
"dt = " <<
dt << std::endl;
85 std::cout <<
"FRAME_RATE = " <<
FRAME_RATE << std::endl;
88 std::cout <<
"currBattery = " << (int)
currBattery << std::endl;
89 std::cout <<
"currHearBeat = " << (int)
currHearBeat << std::endl;
90 std::cout <<
"currDistance = " << (int)
currDistance << std::endl;
91 std::cout <<
"currSpeed = " << (int)
currSpeed << std::endl;
92 std::cout <<
"currDirection = " << (int)
currDirection << std::endl;
93 std::cout <<
"currAngle = " <<
currAngle << std::endl;
98 std::cout <<
"Calculating player position" << std::endl;
114 std::cout <<
"Calculating player rotation" << std::endl;
120 std::cout <<
"Setting break intensity" << std::endl;
129 std::cout <<
"Writting devices" << std::endl;
130 static char info[256];
131 static int chars_written;
137 chars_written = sprintf(info,
"\rSpeed: %i | Heart: %i | Dist: %i | Batt: %i",
148 std::cout <<
"Reading devices" << std::endl;
166 std::cout <<
"Playing" << std::endl;
168 int diff = 0, total = 0, average = 0, i = 0;
169 struct timeval before , after;
176 printf(
"\rmedia: %d", average);
179 gettimeofday(&before ,
NULL);
196 gettimeofday(&after ,
NULL);
203 samples[i_samples++] = diff;
204 if(i_samples == SAMPLES_FPS)
212 usleep((average - diff)*1000);
218 std::cout <<
"Calculating FPS" << std::endl;
void calculatePlayerPosition()
int getData(unsigned char &data)
int getData(unsigned char &data)
static int time_diff(struct timeval x, struct timeval y)
unsigned char currHearBeat
void setPlayerRotation(double x, double y, double z)
int getData(unsigned char &data)
unsigned char currBattery
void calculatePlayerRotation()
int getData(unsigned char &data)
void setInfo(const char *info, int chars_written)
void getXYZW(double *x, double *y, double *z, double *w)
unsigned char currDirection
void setPlayerPosition(double x, double z)
int setData(unsigned char data)