variables inside the main(functionthose names are not for local variables that might just happen to have the same name as global variables they are the global variables any values assigned to them in the main(function will persist outside the main(function we are marking the fpsclock and displaysurf variables as global because they are used in several other functions in the program (more info is at there are four simple rules to determine if variable is local or global if there is global statement for variable at the beginning of the functionthen the variable is global if the name of variable in function has the same name as global variable and the function never assigns the variable valuethen that variable is the global variable if the name of variable in function has the same name as global variable and the function does assign the variable valuethen that variable is local variable if there isn' global variable with the same name as the variable in the functionthen that variable is obviously local variable you generally want to avoid using global variables inside functions function is supposed to be like mini-program inside your program with specific inputs (the parametersand an output (the return valuebut function that reads and writes to global variables has additional inputs and output since the global variable could have been modified in many places before the function was calledit can be tricky to track down bug involving bad value set in the global variable having function as separate mini-program that doesn' use global variables makes it easier to find bugs in your codesince the parameters of the function are clearly known it also makes changing the code in function easiersince if the new function works with the same parameters and gives the same return valueit will automatically work with the rest of the program just like the old function basicallyusing global variables might make it easier to write your program but they generally make it harder to debug in the games in this bookglobal variables are mostly used for variables that would be global constants that never changebut need the pygame init(function called first since this happens in the main(functionthey are set in the main(function and must be global for other functions to see them but the global variables are used as constants and don' changeso they are less likely to cause confusing bugs if you don' understand thisdon' worry just write your code so that you pass in values to functions rather than have the functions read global variables as general rule email questions to the authoral@inventwithpython com