Developing the game program

Now, you can create a project called game. You can copy a project from Chapter 2, Making Visual Data and Animation on an LCD, Weather Project. Figure 3-13 shows our project structure:

Figure 3-13. Project structure for game.

To detect collision between our sprite and circle sprites, we can use a simple method. This involves calculating the distance between our position and circle center point. Then, we compare the point-to-circle distance and circle radius. If our distance is lower than the circle radius, this means that our sprite hits the circle. This is demonstrated in Figure 3-14:

Figure 3-14: A formula to ...

Get Internet of Things Projects with ESP32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.