Beispiel #1
0
    sys.exit(0)


if __name__ == '__main__':

    sim = FireSim(os.getcwd() + "/settings.conf")

    loader = WorldLoader(os.getcwd() + "/" + sim.config['world'])

    sim.world = loader.load()

    if sim.world is None:
        print "No world loaded. Exiting..."
        sys.exit(1)

    sim.setup()
    pygame.init()

    screen = pygame.display.set_mode((sim.width, sim.height))
    pygame.event.set_allowed([QUIT, KEYDOWN, USEREVENT])

    clock = pygame.time.Clock()
    signal.signal(signal.SIGINT, signal_handler)

    server = SimServer(sim.config['listen_addr'], sim.config['listen_port'])
    global_sim_queue = server.get_queue()
    server.start()

    tick_loop = LoopingThread((1.0 / 40.0), sim.tick)
    tick_loop.run()
Beispiel #2
0
def tick():
    rainbow_tick()


def signal_handler(signum, frame):
    global updater, rainbow_loop
    print "Caught signal, exiting..."
    if updater:
        updater.exit_flag = True
        updater.join()
    if rainbow_loop:
        rainbow_loop.stop()
    sys.exit(0)


if __name__ == "__main__":

    n = Node(ip_addr="127.0.0.1", port=5200)

    pixels = [[0, 0, 0] for i in range(160)]
    pixel_queue.put(copy(pixels))

    signal.signal(signal.SIGINT, signal_handler)

    updater = NodeUpdater([n])
    updater.connect()
    updater.start()

    rainbow_loop = LoopingThread((1.0 / 30.0), tick)
    rainbow_loop.run()