<commit_before>import pygame
import sys
from pygame.locals import *
import json
from sounds import SoundManager
from input_manager import InputManager, Actions
import screens, menu

from game_instance import GameInstance

TILESIZE = 10
FPS = 60
BLOCKSIZE = 5
SETTINGS_FILE = "settings.cfg"

config_handle = open(SETTINGS_FILE, "r")
config = json.load(config_handle)
config_handle.close()

pygame.init()
pygame.display.set_caption(config["title"])
pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=4096)
surface = pygame.display.set_mode((config["width"], config["height"]))
game = GameInstance(config, "first")
clock = pygame.time.Clock()
input_manager = InputManager()

screens = {
    "pause":screens.PauseScreen(config),
    "inventory":menu.InventoryMenu(config),
    "complete":screens.CompleteScreen(config),
    "gameover":screens.GameOverScreen(config)
}
"""
main_menu = menu.MainMenu(config, enabled=True)

while True:
    events = input_manager.get_active_events()

    #user closes the game
    if Actions.QUIT in events:
        pygame.quit()
        sys.exit()
    elif Actions.START_GAME in events:
        break

    clock.tick(config["fps"])
    delta = clock.get_time() / 1000.0

    main_menu.doFrame(surface, delta, events)
    pygame.display.update()
"""
input_manager._in_game = True
paused = False

while True:
    events = input_manager.get_active_events()

    #user closes the game
    if Actions.QUIT in events:
        pygame.quit()
        sys.exit()
    elif Actions.GAME_WON in events:
        paused = True
        screens["complete"].enabled = True
    elif Actions.GAME_OVER in events:
        paused = True
        screens["gameover"].enabled = True
    #toggle relevent ui screens
    elif Actions.TOGGLE_PAUSE in events:
        paused = not paused
        screens["pause"].enabled = not screens["pause"].enabled
    elif Actions.TOGGLE_INVENTORY in events:
        paused = not paused
        screens["pause"].enabled = not screens["pause"].enabled
        screens["inventory"].enabled = not screens["inventory"].enabled

    clock.tick(config["fps"])
    delta = clock.get_time() / 1000.0

    #render the game field, a delta of 0 means don't do any physics updates, events of [] means dont perform any inputs
    if paused:
        game.doFrame(surface, 0, [])
    else:
        game.doFrame(surface, delta, events)

    #display any active ui screens
    for screen in screens.itervalues():
        screen.doFrame(surface, delta, events)

    #give it to the user
    pygame.display.update()
<commit_msg>re-enabled title menu<commit_after>import pygame
import sys
from pygame.locals import *
import json
from sounds import SoundManager
from input_manager import InputManager, Actions
import screens, menu

from game_instance import GameInstance

TILESIZE = 10
FPS = 60
BLOCKSIZE = 5
SETTINGS_FILE = "settings.cfg"

config_handle = open(SETTINGS_FILE, "r")
config = json.load(config_handle)
config_handle.close()

pygame.init()
pygame.display.set_caption(config["title"])
pygame.mixer.init(frequency=44100, size=-16, channels=2, buffer=4096)
surface = pygame.display.set_mode((config["width"], config["height"]))
game = GameInstance(config, "first")
clock = pygame.time.Clock()
input_manager = InputManager()

screens = {
    "pause":screens.PauseScreen(config),
    "inventory":menu.InventoryMenu(config),
    "complete":screens.CompleteScreen(config),
    "gameover":screens.GameOverScreen(config)
}

main_menu = menu.MainMenu(config, enabled=True)

while True:
    events = input_manager.get_active_events()

    #user closes the game
    if Actions.QUIT in events:
        pygame.quit()
        sys.exit()
    elif Actions.START_GAME in events:
        break

    clock.tick(config["fps"])
    delta = clock.get_time() / 1000.0

    main_menu.doFrame(surface, delta, events)
    pygame.display.update()

paused = False

while True:
    events = input_manager.get_active_events()

    #user closes the game
    if Actions.QUIT in events:
        pygame.quit()
        sys.exit()
    elif Actions.GAME_WON in events:
        paused = True
        screens["complete"].enabled = True
    elif Actions.GAME_OVER in events:
        paused = True
        screens["gameover"].enabled = True
    #toggle relevent ui screens
    elif Actions.TOGGLE_PAUSE in events:
        paused = not paused
        screens["pause"].enabled = not screens["pause"].enabled
    elif Actions.TOGGLE_INVENTORY in events:
        paused = not paused
        screens["pause"].enabled = not screens["pause"].enabled
        screens["inventory"].enabled = not screens["inventory"].enabled

    clock.tick(config["fps"])
    delta = clock.get_time() / 1000.0

    #render the game field, a delta of 0 means don't do any physics updates, events of [] means dont perform any inputs
    if paused:
        game.doFrame(surface, 0, [])
    else:
        game.doFrame(surface, delta, events)

    #display any active ui screens
    for screen in screens.itervalues():
        screen.doFrame(surface, delta, events)

    #give it to the user
    pygame.display.update()

{'fraction_non_alphanumeric': 0.10986635220125786, 'fraction_numerical': 0.01139937106918239, 'mean_word_length': 3.519538188277087, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1227298', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1542, 'n_words': 404}