Rects and Collision =================== Goals ----- - Extract a ``Rect`` from a Pygame ``Surface`` object (text) to draw a bounding box - Use ``Rect.collidepoint()`` to detect collision between the rect and the mouse (a point) - Use a ``Rect`` to keep track of "sprite" size and location - Use ``Rect.colliderect()`` to detect collision between two ``Rect`` objects. Starter code ------------ :doc:`pygame-template` Video Tutorial -------------- .. raw:: html <iframe width="560" height="315" src="https://www.youtube.com/embed/XYkP27ednzw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> What you need to do ------------------- - Add another mouse over effect - Add a click event using ``MOUSEBUTTONDOWN`` to the text using ``.collidepoint()`` - Add another enemy, when they collide with the player, the player absorbs the enemies. For each ``1`` size lost by enemies, the player gains ``0.5`` size. - Come up with a random (related) idea Final Code ---------- .. literalinclude:: code/rects_and_collision.py :linenos: :emphasize-lines: 29-30, 48, 57