Skip to main content
Engineering LibreTexts

9.2: The Design of Squirrel Eat Squirrel

  • Page ID
  • There are three types of data structures in this game, which are represented as dictionary values. The types are player squirrels, enemy squirrels, and grass objects. There is only one player squirrel object at a time in the game.


    Technically, "object" means something specific in Object-Oriented Programming. Python does have OOP features, but they aren’t covered in this book. Technically the Pygame objects such as "Rect object" or "Surface object" are objects. But I’m going to use the term "object" in this book to refer to "things that exist in the game world". But really, the player squirrel, enemy squirrels, and grass "objects" are just dictionary values.

    All the objects have the following keys in their dictionary value: 'x', 'y', and 'rect'. The 'x' and 'y' key’s value give the coordinates of the top left of the object in game world coordinates. These are different from pixel coordinates (which is what the 'rect' key’s value tracks). The difference between game world and pixel coordinates will be explained when you learn about the concept of cameras.

    In addition, the player squirrel, enemy squirrel, and grass objects have other keys which are explained in a large comment at the start of the source code.