import math

arena_width = 800
arena_height = 600

ship_x = arena_width / 2
ship_y = arena_height / 2
ship_speed_x = 0
ship_speed_y = 0
ship_angle = 0

def update(dt):
    global ship_x
    global ship_y
    global ship_speed_x
    global ship_speed_y
    global ship_angle

    turn_speed = 10

    if keyboard.right:
        ship_angle += turn_speed * dt

    if keyboard.left:
        ship_angle -= turn_speed * dt

    ship_angle %= 2 * math.pi

    if keyboard.up:
        ship_speed = 100
        ship_speed_x += math.cos(ship_angle) * ship_speed * dt
        ship_speed_y += math.sin(ship_angle) * ship_speed * dt

    ship_x += ship_speed_x * dt
    ship_y += ship_speed_y * dt

    ship_x %= arena_width
    ship_y %= arena_height

def draw():
    screen.fill((0, 0, 0))

    screen.draw.filled_circle((ship_x, ship_y), 30, color=(0, 0, 255))

    ship_circle_distance = 20
    screen.draw.filled_circle((
        ship_x + math.cos(ship_angle) * ship_circle_distance,
        ship_y + math.sin(ship_angle) * ship_circle_distance),
        5, color=(0, 255, 255)
    )

    # Temporary
    screen.draw.text(
        'ship_angle: ' + str(ship_angle) + '\n' +
        'ship_x: ' + str(ship_x) + '\n' +
        'ship_y: ' + str(ship_y) + '\n' +
        'ship_speed_x: ' + str(ship_speed_x) + '\n' +
        'ship_speed_y: ' + str(ship_speed_y),
    (0, 0))