예제 #1
0
def start_singleplayer(name, addr):
    if os.fork():
        serverengine.initialize(addr[1])
        serverengine.start()
    else:
        time.sleep(0.2)
        clientengine.initialize(name, addr)
        clientengine.start()
예제 #2
0
def main():
    args = parse_args()
    setup_logging(args.verbose)

    if args.single_player:
        logging.info("Running in single player mode...")
        start_singleplayer(args.name, (args.host, args.port))
        return

    gameengine = None
    if args.listen:
        logging.info("Running in server mode...")
        serverengine.initialize(args.port)
        gameengine = serverengine
    else:
        logging.info("Running in client mode...")
        clientengine.initialize(args.name, (args.host, args.port))
        gameengine = clientengine
    gameengine.start()