I noticed you multiplied two vector 2D variables 'speed' and 'direction'. Is this a dot product multiplication?
No, dot product is a different operation, often used to indirectly compare angles between vectors.
You'd write it like so: speed.dot(direction)
.
Instead, speed * direction is a per-member multiplication. It's equivalent to:
Vector2(speed.x * direction.x, speed.y * direction.y)