if ['dir'=upleftb['rect'left -movespeed ['rect'top -movespeed if ['dir'=uprightb['rect'left +movespeed ['rect'top -movespeed check if the block has move out of the window if ['rect'top block has moved past the top if ['dir'=upleftb['dir'downleft if ['dir'=uprightb['dir'downright if ['rect'bottom windowheightblock has moved past the bottom if ['dir'=downleftb['dir'upleft if ['dir'=downrightb['dir'upright 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 draw the block onto the surface pygame draw rect(windowsurfaceb['color'] ['rect']draw the window onto the screen pygame display update(time sleep(