defining functions there are several functions you'll create for the game def terminate() pygame quit( sys exit(pygame requires that you call both pygame quit(and sys exit(put them both into function called terminate(now you only need to call terminate()instead of both of the pygame quit(and sys exit(functions def waitforplayertopresskey() while true for event in pygame event get()sometimes you'll want to pause the game until the player presses key create new function called waitforplayertopresskey(inside this functionthere' an infinite loop that only breaks when keydown or quit event is received at the start of the looppygame event get(to return list of event objects to check out if event type =quitterminate(if the player has closed the window while the program is waiting for the player to press keypygame will generate quit event in that casecall the terminate(function on line if event type =keydownif event key =k_escapepressing escape quits terminate(return if you receive keydown eventthen you should first check if it is the esc key that was pressed if the player presses the esc keythe program should terminate if that wasn' the casethen execution will skip the if-block on line and go straight to the return statementwhich exits the waitforplayertopresskey(function if quit or keydown event isn' generatedthen the code keeps looping since the loop does nothingthis will make it look like the game has frozen until the player presses key def playerhashitbaddie(playerrectbaddies) for in baddies