That can be done with other module. One of my modules is called GAME_LOOP. It store another module and call the following functions. init_: Called once to create all the sprites and arrays. destroy_: Clear all the sprites and free the memory of the arrays. input_: Handle the input of the player. update_: Handle the logic of the game. render_: self explanatory.