Part 12: Objects as pygame Sprites

pygame has something called sprites, actors in the game. It is to facilitate easy drawing, creation, and destruction of the actors. The actors are objects(instances of the class) technically. And the classes inherit (inherit all features from the parent and have some more of their own) from pygame.sprite.Sprite Now, to build upon the game, let… Continue reading Part 12: Objects as pygame Sprites

Part 11: OOP Introduced – Detect collision for multiple objects

Now to leverage the power of Object oriented programming. Suppose we have multiple walls(rectangles), where shall we store the Pygame.Rect’s that we need? Will we write 100 such lines for 100 walls? circlerect.colliderect(wallrect) The answer is we create a “Wall” class which is akin to a cookie cutter mould for all the walls (it is… Continue reading Part 11: OOP Introduced – Detect collision for multiple objects