79266830

Date: 2024-12-10 01:52:48
Score: 1
Natty:
Report link

When moving diagonally, you're applying an offset of magnitude speed in two directions at once for a total diagonal offset of sqrt(speed^2 + speed^2) = sqrt(2) * speed ≈ 1.414 * speed. To prevent this, just normalize the movement to have a magnitude of speed. You can store the offset in a vector and use scale_to_length to do so, or you can just divide the x and y offsets by sqrt(2) if a horizontal and vertical key are both pressed.

Reasons:
  • Has code block (-0.5):
  • Single line (0.5):
  • Starts with a question (0.5): When
  • Low reputation (0.5):
Posted by: tenuki