icfp11/src/simulate.c

36 lines
1021 B
C
Raw Normal View History

2008-07-12 15:50:24 +00:00
#include "control.h"
#include <math.h>
#define LATENCY 20
static double fixdir(double a) {
if (a < 0) a += 360;
else if (a > 360) a -= 360;
return a;
}
void simulate(trial *t) {
double move, angle;
timestamp now = getcurts(t) + LATENCY, diff = now - t->sim.ts;
if (diff < 20) return;
/* move = t->sim.vehicle.speed / 1000 * diff;
angle = t->sim.vehicle.dir*M_PI/180;
t->sim.vehicle.x += cos(angle)*move;
t->sim.vehicle.y += sin(angle)*move;*/
/* switch (t->sim.vehicle.turn) {
case TURN_HARD_LEFT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir + t->map.max_hard_turn); break;
case TURN_LEFT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir + t->map.max_turn); break;
case TURN_STRAIGHT : break;
case TURN_RIGHT : t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir - t->map.max_turn); break;
case TURN_HARD_RIGHT: t->sim.vehicle.dir = fixdir(t->sim.vehicle.dir - t->map.max_hard_turn); break;
}
t->sim.vehicle.accel = t->vehicle.accel;
t->sim.vehicle.turn = t->vehicle.turn;*/
}