Tracking game state is no different than tracking state in any other Prolog program. You define facts and then use them to make decisions. It's pretty old, but the article Exploring Prolog : Adventures, Objects, Animals, and Taxes does a good job of explaining how this might work in a game. Summarized from the article:
% Set up - you start in a house
% Move to a new location.
location(you, L), % Read your current location into L
connect(L, X), % Check if you can reach the new location X from L
retract( location(you, L) ), % Remove the old location fact
assert( location(you, X) ). % Add a new location fact. You are in X now.
write($ You are in the $), write(X), nl.
Beyond that, you need a graphics and IO library. There may be commercial Prolog distributions that include them. I'm most familiar with SWI Prolog, so I'll suggest plOpenGL as a starting point. Not only does it give you access to OpenGL's rendering capabilities, it also includes bindings for mouse and keyboard events. For example, to handle a press of the Escape key, you define a keyboard rule like so:
% 27 is ASCII Code for Escape
write('Escape key was pressed...'),nl.
Take a look at plOpenGL's moving light example for a few more details and an example of handling mouse movement.
If you use a graphics library, it will likely handle the game loop for you. Basically, you invert control to the library and provide rules to be executed when appropriate: set up, repainting, IO events, etc. If you want to limit FPS or run code conditionally based on time, you can track elapsed time using time/date predicates and make decisions accordingly.
There are many Prolog flavors, so this is certainly not the only way to build a game. Different distributions and related languages will use different libraries/bindings that may encourage different approaches. In addition, polyglot programmers might encourage you to use a more "graphics friendly" host language/runtime to manage rendering and IO while using Prolog to model game entity behaviors and decision making.