def new_game(): """ Makes new game by deleting old data and making new data """ global CURRENT_FLOOR, TURN_COUNT, MAP_INFO, CAMERA, PATHFINDING, PLAYER, GAME_DATA, FOV CURRENT_FLOOR = 1 # Save this TURN_COUNT = 0 # Save this MAP_INFO = gamemap.MapInfo() CAMERA = camera.Camera(MAP_INFO) PATHFINDING = pathfinding.Graph() PATHFINDING.make_graph(MAP_INFO) PATHFINDING.neighbour() # Save this PLAYER = entity_generator.generate_player(MAP_INFO.map_tree, "knight") # Save this GAME_DATA = game_data.GameData() FOV = fov.new_fov(MAP_INFO) PARTICLE_LIST = []
def __init__(self): self.players = [Player() for i in range(3)] self.round = 1 self.winning_player = 0 self.curr_player = 0 self.curr_clue_row = 0 self.curr_clue_col = 0 self.wager_mode = False self.base_clue_value = CLUE_MULT * self.round self.curr_clue_value = self.curr_clue_row * self.base_clue_value self.data = gd.GameData() self.get_round_data(self.round) self.assign_daily_double() self.answer_timer = None self.sounds = { 'daily_double' : "resources/sounds/daily-double.mp3", 'final_jep' : "resources/sounds/final-jep.mp3", 'jeopardy_theme' : "resources/sounds/jeopardy-theme.mp3", 'times_up' : "resources/sounds/times-up.mp3" }
def __init__(self, hostname, port, n_clients, n_iterations, sim_name): #Create history object for this simulation self.gamehistory = game_history.GameHistory(sim_name) self.gamedata = game_data.GameData() #Program Process #Initialize Server with Values print("Started game at " + hostname + ':' + str(port)) self.hostname = hostname self.port = port #Creating and binding a server socket to a port self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.sock.bind((hostname, port)) except socket.error as e: return #Waiting for and connecting to clients print('Waiting for ' + str(n_clients) + ' clients...') self.sock.listen(n_clients) #Accepting connections and saving them for c in range(0, n_clients): conn, addr = self.sock.accept() self.connections.append(conn) print('Client ' + str(len(self.connections) - 1) + ' Connected at: ' + str(addr[0]) + ':' + str(addr[1])) self.gamedata.players.append( game_data.Player(c, float(random.randint(-8000, 8000)), float(random.randint(-8000, 8000)), float(random.randint(0, 360)))) print('\tExchanging init information...') cli_init = socket_utilities.recv_data(conn) cli_init = socket_utilities.convert_to_object(cli_init) ser_init = init_message.InitMessageFromServer(c) ser_init = socket_utilities.convert_to_bytes(ser_init) socket_utilities.send_data(conn, ser_init) print('\tFinished exchanging init information...\n') #Starting Game Process print('Starting ' + str(n_iterations) + ' iterations...') start = time.time() for c in self.connections: #c.send('START'.encode()) socket_utilities.send_data(c, 'START'.encode()) for i in range(0, n_iterations): if self.gamedata.game_over: break self.broadcast_game_data() given = self.receive_client_inputs() self.process_game_data(given) if (not self.gamedata.game_over): self.gamedata.game_over = True print("The game ended in a draw!") #Saves last bit of data if not self.gamehistory.is_empty(): self.gamehistory.save_to_file() #Closes client connections self.close_connections() #print(self.gamedatahistory) print('Simulation ending...') print('Elapsed time: ' + str(time.time() - start))
#colors that are used frequently black = (0, 0, 0) white = (255, 255, 255) #creating font game_font_path = os.path.join(my_path, '../Fonts/Atari.ttf') gameFont = pygame.font.Font(game_font_path, 28) title_font_path = os.path.join(my_path, "../Fonts/SPACEBAR.ttf") title_font = pygame.font.Font(title_font_path, 32) #framerate clock clock = pygame.time.Clock() #game data object data = game_data.GameData() #<----------Main Menu----------> def MainMenu(): data.score = 0 data.curr_level = 1 data.alien_speed = 850 data.alien_y = 40 icon_path = os.path.join(my_path, '../Images/icon.png') icon = pygame.image.load(icon_path) pygame.display.set_icon(icon) startButton = pygame.Rect(190, 140, 256, 64) high_score_button = pygame.Rect(190, 224, 256, 64)
TURN_COUNT = 0 # Save this MAP_INFO = gamemap.MapInfo() CAMERA = camera.Camera(MAP_INFO) PATHFINDING = pathfinding.Graph() PATHFINDING.make_graph(MAP_INFO) PATHFINDING.neighbour() # Save this PLAYER = entity_generator.generate_player(MAP_INFO.map_tree, "knight") # Save this GAME_DATA = game_data.GameData() FOV = fov.new_fov(MAP_INFO) PARTICLE_LIST = [] WALL_HACK = False MINIMAP = False BUTTON_PANEL = buttonmanager.GridButtonManager( SURFACE_MAIN.get_width() - (SPRITE_SIZE * ((TILE_WIDTH // 2) + (NUM_OF_BUTTONS_X // 2))), SURFACE_MAIN.get_height() - SPRITE_SIZE, NUM_OF_BUTTONS_X, NUM_OF_BUTTONS_Y, (NUM_OF_BUTTONS_X * NUM_OF_BUTTONS_Y), BLACK)