How does the game loop actually work?

Also I see i need practice scoping through source files.