예제 #1
0
    def __init__(self, args):
        """ BoomBoomClient constructor.
        @param host: Server hostname.
        @type host: C{str}
        @param display_port: Server port for "display"/"view" connection.
        @type display_port: C{int}
        @param input_port: Server port for "input" connection.
        @type input_port: C{int}
        @param verbose: Verbose mode flag.
        @type verbose: C{bool}
        @param debug: Debug mode flag.
        @type debug: C{bool}
        @param max_fps: Maximal number of frames per second, for optimization.
        @type max_fps: C{int}
        """
        args["protocol"] = protocol.loadProtocol("protocol.xml")
        args["features"] = ["game"]  # Constant features

        Happyboom.__init__(self, args)
        EventListener.__init__(self, prefix="evt_")

        self.display = Display(args)
        self.input = Input(args)
        self.__verbose = args.get("verbose", False)
        self.registerEvent("happyboom")
        self.registerEvent("game")
예제 #2
0
 def __init__(self, args):
     """ BoomBoomClient constructor.
     @param host: Server hostname.
     @type host: C{str}
     @param display_port: Server port for "display"/"view" connection.
     @type display_port: C{int}
     @param input_port: Server port for "input" connection.
     @type input_port: C{int}
     @param verbose: Verbose mode flag.
     @type verbose: C{bool}
     @param debug: Debug mode flag.
     @type debug: C{bool}
     @param max_fps: Maximal number of frames per second, for optimization.
     @type max_fps: C{int}
     """
     args["protocol"] = protocol.loadProtocol("protocol.xml")
     args["features"] = ["game"] # Constant features
     
     Happyboom.__init__(self, args)
     EventListener.__init__(self, prefix="evt_")
     
     self.display = Display(args)
     self.input = Input(args)
     self.__verbose = args.get("verbose", False)
     self.registerEvent("happyboom")
     self.registerEvent("game")        
def main():
    # Add HappyBoom to PYTHONPATH
    import sys, os
    file_dir = os.path.dirname(__file__)
    happyboomdir = os.path.join(file_dir, "..", "happyboom", "trunk")
    sys.path.append(happyboomdir)

    # Get user directory
    from happyboom.common.file import getCreateHomeDir
    logdir = getCreateHomeDir("boomboom")

    # Setup log filename
    from happyboom.common.log import log
    if logdir != None:
        logname = os.path.join(logdir, "server-log")
        log.setFilename(logname)

    # Read command line arguments
    val = { \
        "input_port": 12430,
        "max_clients": 4,
        "verbose": False,
        "debug": False}
    arg = parseArgs(val)

    # Create BoomBoom server
    from server.bb_server import Server
    from happyboom.common.protocol import loadProtocol
    protocol = loadProtocol("protocol.xml")
    server = Server(protocol, arg)

    # Main loop
    try:
        server.start()
    except KeyboardInterrupt:
        log.info("Program interrupted (CTRL+C).")
        pass

    # Stop the server
    server.stop()
def main():
    # Add HappyBoom to PYTHONPATH
    import sys, os
    file_dir = os.path.dirname(__file__)
    happyboomdir = os.path.join(file_dir, "..", "happyboom", "trunk")
    sys.path.append(happyboomdir)

    # Get user directory 
    from happyboom.common.file import getCreateHomeDir
    logdir = getCreateHomeDir("boomboom")

    # Setup log filename
    from happyboom.common.log import log
    if logdir != None:
        logname = os.path.join(logdir, "server-log")    
        log.setFilename(logname)
   
    # Read command line arguments
    val = { \
        "input_port": 12430,
        "max_clients": 4,
        "verbose": False,
        "debug": False}
    arg = parseArgs(val)
   
    # Create BoomBoom server
    from server.bb_server import Server
    from happyboom.common.protocol import loadProtocol
    protocol = loadProtocol("protocol.xml")
    server = Server(protocol, arg)

    # Main loop
    try:
        server.start()
    except KeyboardInterrupt:
        log.info("Program interrupted (CTRL+C).")
        pass
    
    # Stop the server
    server.stop()