Extract non-game specific functions.

Storing those functions in util.js file separates the game logic
from the more generic framework code.