Importing Images ================ Goals ----- - Importing and drawing images (imported as ``pygame.Surface``) - Extracting a ``pygame.Rect`` from the image to use as a game object (for collision and movement). - Understand transparency (png) and the importance of cropping your image files. - ``pygame.Surface.set_alpha(int) -> None`` - Check pygame docs for various ``pygame.transform`` methods to use on ``pygame.Surface`` s. - ``pygame.transform.flip(surface: Surface, flip_x: bool, flip_y: bool) -> Surface`` - ``pygame.transform.scale(surface: Surface, size: Tuple[int, int], dest_surface: Surface = None) -> Surface`` - ``pygame.transform.rotate(surface: Surface, degrees: float) -> Surface`` Required Files -------------- - :doc:`pygame-template` - :download:`fishGreen.png <../images/fishGreen.png>` Video Tutorial -------------- Not done yet, sorry. What you need to do ------------------- - When you click the fish make it grow. You will need to scale the image as well as update the ``fish_rect``. - Add the ability to move the fish left and right with the keyboard. - When the fish moves, flip the image to have the fish look in that direction. Final Code ---------- .. literalinclude:: code/importing_images_final.py :linenos: :emphasize-lines: 19, 57