## Overview

Simulation of a pod's movement consists of 3 steps:

- game action is applied
- 1 game second of physics being simulated
- friction is applied

## Applying a game action

Since a game action is just some angle and thrust, we just need to add move's angle to the pod's rotation, multiply pod's facing vector by thrust and add it to the velocity vector:

```
this.angle += move.angle;
var direction = new Vector(Math.Cos(this.angle), Math.Sin(this.angle));
this.velocity += direction * move.thrust;
```

## Simulating physics of a single pod

A pod's physics is only static movement, so we just need to "apply" velocity:

```
this.position += this.velocity*time;
```

We need to multiply velocity by time to be able to simulate less than 1 game second for collision simulation

## Applying friction

Friction just takes 15% of velocity:

```
this.velocity -= this.velocity*0.15;
```

Or simpler:

```
this.velocity *= (1 - 0.15);
```

## Basic pod class

```
class Pod
{
Vector2 position;
Vector2 velocity;
float angle;
Checkpoint targetCP;
int lap;
```

## Writing functions for movement simulation.

```
void Move(float time)
{
while(GetTimeToCollision(position, velocity, targetCP.position, Vector2.Zero, 600))
{
targetCP = targetCP.next;
if (targetCP.id == 1)
lap++;
}
this.position += this.velocity*time;
}
void FinishTurn(float time)
{
this.position.Truncate();
this.velocity.Round();
}
}
```