tick & update
function tick(v,t) {
if(oldTick == 0) {
oldTick = v;
}
while (oldTick < v) {
update();
oldTick = oldTick + 0.05;
}
}
function update() {
// Y-as wordt eigenlijkniet gebruikt, beweging
// i beperkt tot x/z vlak,
// maar voor de volledigheid wordt het wel
// allemaal netjes berekend...
if(space) {
hide_text = -1;
}
// Up/Down = gas/rem
if(upk) {
speed = speed + 0.01;
}
if(down) {
speed = speed - 0.01;
}
// Left/Right = sturen
// Eigenlijk zou snelheid sturen moeten beinvloeden
if(left) {
direction = (new SFRotation(0,1,0, 0.1)).multVec(direction);
}
if(right) {
direction = (new SFRotation(0,1,0,-0.1)).multVec(direction);
}
// verplaats object
position[0] = position[0] + direction[0]*speed;
position[1] = position[1] + direction[1]*speed;
position[2] = position[2] + direction[2]*speed;
position_changed = position;
// output de juiste updates
rotA = new SFRotation(defDirection,direction);
up = rotA.multVec(yAxis);
rotB = new SFRotation(direction.cross(up),
direction.cross(yAxis));
orientation = rotA.multiply(rotB);
orientation_changed = orientation;
}
"
}