pygame time wait( pause so the player can suffer in their defeat if resetgame start new game mainboard generaterandomboard(boardwidthboardheightdifficulty life maxlife lastpaletteclicked none pygame display update( fpsclock tick(fps def checkforquit() terminates the program if there are any quit or escape key events for event in pygame event get(quit)get all the quit events pygame quit(terminate if any quit events are present sys exit( for event in pygame event get(keyup)get all the keyup events if event key =k_escape pygame quit(terminate if the keyup event was for the esc key sys exit( pygame event post(eventput the other keyup event objects back def haswon(board) if the entire board is the same colorplayer has won for in range(boardwidth) for in range(boardheight) if board[ ][ !board[ ][ ] return false found different colorplayer has not won return true def showsettingsscreen() global difficultyboxsizeboardwidthboardheightmaxlifepalettecolorsbgcolor the pixel coordinates in this function were obtained by loading the inkspillsettings png image into graphics editor and reading the pixel coordinates from there handy trick origdifficulty difficulty origboxsize boxsize