if ['rect'left block has moved past the left side if ['dir'=downleftb['dir'downright if ['dir'=upleftb['dir'upright if ['rect'right windowwidthblock has moved past the right side if ['dir'=downrightb['dir'downleft if ['dir'=uprightb['dir'upleft lines to are similar to lines to but checks if the left side of the block has moved to the left of the left edge of the window rememberthe -coordinates start at on the left edge of the window and increase to windowwidth on the right edge of the window drawing the blocks on the window in their new positions draw the block onto the surface pygame draw rect(windowsurfaceb['color'] ['rect']now that the blocks have movedthey should be drawn in their new positions on the windowsurface surface by calling the pygame draw rect(function pass windowsurface because it is the surface object to draw the rectangle on pass the ['color'because it is the color of the rectangle pass ['rect'because it is the rect object with the position and size of the rectangle to draw line is the last line of the for loop if you wanted to add new blocksyou only have to modify the blocks list on line and the rest of the code still works drawing the window on the screen draw the window onto the screen pygame display update(time sleep( after each of the blocks in the blocks list has been drawncall pygame display update(so that the windowsurface surface is draw on the screen post questions to