building games with pygame rectangles (or rectsthe pygame rect class is an object used to represent rectangular coordinates rect can be created from combination of the top left corner coordinates plus width and height for flexibility many functions that expect rect object can also be given rectlike listthis is list that contains the data necessary to create rect object rects are very useful in pygame game as they can be used to define the borders of game object this means that they can be used within games to detect if two objects have collided this is made particularly easy because the rect class provides several collision detection methodspygame rect contains(test if one rectangle is inside another pygame rect collidepoint(test if point is inside rectangle pygame rect colliderect(test if two rectangles overlap pygame rect collidelist(test if one rectangle in list intersects pygame rect collidelistall(test if all rectangles in list intersect pygame rect collidedict(test if one rectangle in dictionary intersects pygame rect collidedictall(test if all rectangles in dictionary intersect the class also provides several other utility methods such as move(which moves the rectangle and inflate(which can grow or shrink the rectangles size drawing shapes the pygame draw module has numerous functions that can be used to draw lines and shapes onto surfacefor examplepygame draw rect(display_surfaceblue[xywidthheight]this will draw filled blue rectangle (the defaultonto the display surface the rectangle will be located at the location indicated by and (on the surfacethis indicates the top left hand corner of the rectangle the width and height of the rectangle indicate its size note that these dimensions are defined within list which is structure referred to as being rect like (see belowif you do not want filled rectangle ( you just want the outlinethen you can use the optional width parameter to indicate the thickness of the outer edge other methods available includepygame draw polygon(draw shape with any number of sides pygame draw circle(draw circle around point pygame draw ellipse(draw round shape inside rectangle pygame draw arc(draw partial section of an ellipse pygame draw line(draw straight line segment pygame draw lines(draw multiple contiguous line segments pygame draw aaline(draw fine antialiased lines pygame draw aalines(draw connected sequence of antialiased lines