function update(game: Game, entity: Entity) {
let control = game.World.ControlPlayer[entity];
if (control.Move) {
let move = game.World.Move[entity];
if (Math.abs(game.InputDelta["pad0_axis_1"]) > DEAD_ZONE) {
move.Direction[0] -= game.InputDelta["pad0_axis_1"];
}
if (Math.abs(game.InputDelta["pad0_axis_2"]) > DEAD_ZONE) {
move.Direction[2] -= game.InputDelta["pad0_axis_2"];
}
}
if (control.Yaw && Math.abs(game.InputDelta["pad0_axis_3"]) > DEAD_ZONE) {
let move = game.World.Move[entity];
let amount = game.InputDelta["pad0_axis_3"] * Math.PI;
quat_multiply(
move.LocalRotation,
move.LocalRotation,
quat_from_axis([0, 0, 0, 1], AXIS_Y, -amount)
);
}
if (control.Pitch && Math.abs(game.InputDelta["pad0_axis_4"]) > DEAD_ZONE) {
let transform = game.World.Transform[entity];
let move = game.World.Move[entity];
let amount = game.InputDelta["pad0_axis_4"] * Math.PI;
let current_pitch = quat_get_pitch(transform.Rotation);
if (
(amount < 0 && current_pitch > control.MinPitch) ||
(amount > 0 && current_pitch < control.MaxPitch)
) {
quat_multiply(
move.SelfRotation,
move.SelfRotation,
quat_from_axis([0, 0, 0, 1], AXIS_X, amount)
);
}
}
}