Esempio n. 1
0
def magestic_ending():
    print("Boom!")
    boxes = [""]
    explode = arena.Object( location=(pinata_loc[0],pinata_loc[1],pinata_loc[2]),data='{"sound":{"positional":true,"poolSize":8,"src":"store/users/wiselab/audio/explode.wav","autoplay":"true"}}')
    explode.delete()
    for i in range(NUM_BOXES):
        x=arena.Object(
        objType=arena.Shape.cube,
        persist=False,
        objName="cube"+str(i),
        # messes up child-follow-parent pose
        physics=arena.Physics.dynamic,
        collision_listener=False,
        #transparency=arena.Transparency(True,0.5),
        impulse=arena.Impulse("mouseup",( 5,30,0),(30,1,1)),
#        location=(random.randrange(AREA_X_START,AREA_X_STOP), 10, random.randrange(AREA_Y_START,AREA_Y_STOP)),
        location=(pinata_loc[0], pinata_loc[1]+1.5, pinata_loc[2] ),
        color=random_color(),
        scale=(0.6, 0.6, 0.6),
        clickable=False,
        callback=box_callback,
        )
        boxes.append(x)
    time.sleep(0.5)
    clap = arena.Object( location=(pinata_loc[0],pinata_loc[1],pinata_loc[2]),data='{"sound":{"positional":true,"poolSize":8,"src":"store/users/wiselab/audio/applause.wav","autoplay":"true"}}')
    clap.delete()
    time.sleep(2.0)
    clap = arena.Object( location=(pinata_loc[0],pinata_loc[1],pinata_loc[2]),data='{"sound":{"positional":true,"poolSize":8,"src":"store/users/wiselab/audio/applause.wav","autoplay":"true"}}')
    clap.delete()
    time.sleep(7)
    for i in range(NUM_BOXES):
        x=boxes.pop()
        x.delete()
Esempio n. 2
0
def initCube(x, y, color):
    name = "cube_" + str(x) + "_" + str(y)
    cubes[(x, y)] = childObject(
        objType=arena.Shape.cube,
        persist=True,
        objName=name,
        # messes up child-follow-parent pose
        # physics=arena.Physics.static,
        collision_listener=True,
        transparency=arena.Transparency(True,0.5),
        impulse=arena.Impulse("mouseup",(0,40,0),(10,1,1)),
        location=(x, y, -3),
        color=color,
        scale=(0.6, 0.6, 0.6),
        clickable=True,
        callback=guac_callback,
    )
Esempio n. 3
0
def guac_callback(event=None):  # gets a GenericEvent

    global counter

    # only mousedown messages
    if event.event_type == arena.EventType.mousedown:

        # draw a ray from clicker to cube
        draw_ray(event.click_pos, event.position)

        color = redblue[counter % 2]
        x = int(event.object_id.split("_")[1])
        y = int(event.object_id.split("_")[2])
        if grid[(x - 1)][(y - 1)] != -1:
            return
        counter = counter + 1
        grid[(x - 1)][(y - 1)] = counter % 2
        cubes[(x, y)].update(
            #physics=arena.Physics.static,
            color=color,
            impulse=arena.Impulse("mouseup", (0, 10, 0), (10, 1, 1)),
            transparency=arena.Transparency(False, 1),
            clickable=True,
            location=(x, y, -3),
            scale=(0.6, 0.6, 0.6),
        )

        winColor = solved()
        if winColor != -1:
            draw_hud(winColor)
            print("solved")
            animate_win()
            draw_board()
        if stalemate():
            draw_hud(-1)
            print("stalemate")
            animate_loss()
            draw_board()

    else:
        return
Esempio n. 4
0
# start the fun shall we?

arena.init(HOST, REALM, SCENE)
# make a parent scene object
print("starting main loop")

#    name = "cube_" + str(x) + "_" + str(y)

for i in range(100):

    arena.Object(
        objType=arena.Shape.cube,
        persist=False,
        objName="cube" + str(i),
        # messes up child-follow-parent pose
        physics=arena.Physics.dynamic,
        collision_listener=True,
        #transparency=arena.Transparency(True,0.5),
        impulse=arena.Impulse("mouseup", (5, 30, 0), (30, 1, 1)),
        location=(random.randrange(-10, 10), 1, random.randrange(-10, 10)),
        color=random_color(),
        scale=(0.6, 0.6, 0.6),
        clickable=True,
        callback=guac_callback,
    )

#cube1.delete()

arena.handle_events()