def main(): help_string = """ usage: python main.py <IP_ADDR> <PORT> <ACTION> IP_ADDR : IP address of the server/client PORT : Port number of the server/client Action : specifies wether you want to send or listen Actions: --listen (listens for a connection on the specifed port) --send (sends appended string from mozilla settings) """ script, ip, port, action = sys.argv if action == "--help": print(help_string) elif action == '--listen': server.listen(ip, port) elif action == '--send': system_os = platform.system() links = browser.retrieve_next_session_links(system_os) client.send(links, ip , port)
def run(): play_time = 0 clock = pygame.time.Clock() while state == RUNNING: ms = clock.tick(60) play_time += ms / 1000.0 # handle player inputs action = controls.process_events() controls.update_keys() # debug actions if action == "shoot": player1.shoot() elif action == "spawn_item": DroppedPerk(ab, player1.rect.move(30, 0).center) elif action == "spawn_gun": player1.add_weapon(Gun((0, 0))) elif action == "swap_gun": player1.swap_weapons() elif action == "host": if not is_host: init_host() elif action == "connect": if not is_host: init_net() elif action == "test_sock": client.send("hello") # update cursor cursor_pos_x, cursor_pos_y = pygame.mouse.get_pos() cursor.move((cursor_pos_x / options.scale(), cursor_pos_y / options.scale()), controls.click) # update cursor text cursor.set_hover_text(examine.find_examine_text(cursor.point())) # update window title to show frame rate pygame.display.set_caption("FPS: {0:.2f}".format(clock.get_fps())) # update player with cursor information player1.update_cursor(cursor, camera) # flip player to face cursor # player1.flip(cursor.point()[0] < camera.apply(player1.rect).centerx) perk_collide(player1) # render screen render.draw() # update the camera to the player's position camera.follow(player1.rect)