update method

void update()

Implementation

void update() {
  x += cos(direction) * speed;
  y += sin(direction) * speed;

  // Wrap around screen edges
  if (x > 1.0) x = 0.0;
  if (x < 0.0) x = 1.0;
  if (y > 1.0) y = 0.0;
  if (y < 0.0) y = 1.0;
}