Apple Game Frameworks and Technologies: Calculate Speed, why divide by 255? (pg. 50)

@Paradox927 - Just curious to know how you came up with 255 when calculating the speed, on page 60 in the PDF.

    let calculatedSpeed = TimeInterval(distance / playerSpeed) / 255

The code notes, and footnotes are great for illuminating the programmatic choices made, but the 255 number seems arbitrary without any immediate insight into the choice, and likely something that can be dynamically changed.

Anyways, any insight provided would be great, and thanks in advance!

Great question!

The 255 was a somewhat arbitrary number based on how the movement speed “felt” during gameplay.

I suppose I could have used a dynamic number—for example, Double(frame.size.width) or something along those lines—but in this case, it didn’t much matter, so I went with a hard-coded number instead.

Arbitrary is good! lol

So much of what we do ends up tailored to the User eXperience, and sussing out an elegant math solution - though fun in its own right - is typically less relevant or necessary, and often less expedient than just getting it to market. :slight_smile:

Thanks of taking the time to answer, and I’m really enjoying the book!