Apple Game Frameworks and Technologies: Distance calc could be simpler for this point of the book (p 54)

Hi, David.

Thank you for the suggestion.

I considered using that simpler solution as I was writing this chapter, but I ultimately decided to use the one you see in the book. I did so for the following reasons:

  1. The variation in speed when tapping on the platform versus tapping above it is marginal. Actually, most players probably wouldn’t notice the difference. I’m impressed you caught it. :grin:

  2. Later in the book, the player controls are modified to use an attached controller-knob (for lack of a better term), which also removes the ability to tap the screen to move, consequently removing the minor speed consistency issue.

  3. Readers will likely want to apply this technique to their own games, which may include a character that has a full range of motion. That being the case, I wanted to use this solution, here, because new developers may not know about the hypot() function whereas the abs() function is more common. To be honest, this reason was the primary motivating factor.

After reading your comment, I considered adding a note somewhere about using abs() as an alternative, but this being an already complex topic, I don’t want to muddy the waters. I may, eventually, add a note, but for now, I’m going to leave it as-is.

Thanks again for all of your recent comments. I appreciate your help in making this book a valuable and acurate resource.

2 Likes