Пример #1
0
def next_level():
    global flowers, bullets, level, level_text_brightness, clouds, bees, num_bees, baske, ba

    level += 1

    player1.level_up(level)

    ba = basket.Basket()
    baske = []

    clouds = []
    for i in range(random.randint(4,8)):
        clouds.append(cloud.Cloud(screen_size))

    flowers = []
    for i in range(2*level):
        flowers.append(flower.Flower([
            random.randint(0,screen_size[0]),
            random.randint(0,screen_size[1])
        ]))

    bees = []
    for i in range(num_bees):
        bees.append(bee.Bee(screen_size))
    if level%7 == 0:
        num_bees += 1

    level_text_brightness = 1.0
Пример #2
0
def main():
    # DATA
    # Holds the information about game logic state (game or manual)
    autonomy = threading.Event()
    autonomy.clear()
    # Stop signal for all threads
    stop_flag = threading.Event()
    stop_flag.clear()

    # For remotely changing thrower speed (works with robot_thrower_calibration as r)
    q_thrower_speed = queue.Queue()

    # OBJECTS
    basket = bask.Basket("thresh/thresh_basket_pink.txt")
    balls = ball.Balls("thresh/thresh_ball.txt")
    camera_thread = cam.ImageCapRS2(stop_flag)
    camera = cam.Camera(basket, balls, camera_thread, stop_flag)
    mainboard = r.Mainboard(autonomy, stop_flag)
    # For testing only thrower using remote control
    #robot = r.Robot(mainboard, camera, autonomy, stop_flag, balls, basket, q_thrower_speed)
    robot = r.Robot(mainboard, camera, autonomy, stop_flag, balls, basket)

    # Manual control
    thread_manual_control = threading.Thread(name="manual",
                                             target=remote_control.gamepad,
                                             args=(mainboard, autonomy,
                                                   stop_flag, q_thrower_speed),
                                             daemon=True)
    thread_manual_control.start()

    # The main loop for our program, use to display values etc
    robot.autopilot()
Пример #3
0
def main():
    # DATA
    # Holds the information about game logic state (game or manual)
    autonomy = threading.Event()
    # By default this should be set so that the robot starts autonomously
    autonomy.set()
    # Stop signal for all threads
    stop_flag = threading.Event()
    stop_flag.clear()

    # OBJECTS
    basket = bask.Basket("thresh/thresh_basket.txt")
    balls = ball.Balls("thresh/thresh_ball.txt")

    #xbee = xb.Xbee()
    camera = cam.Camera(basket, balls, stop_flag)
    mainboard = r.Mainboard(autonomy, stop_flag)
    robot = r.Robot(mainboard, camera, autonomy, stop_flag, balls, basket)

    # Returns the horizontal position of the ball
    #thread_image_processing = threading.Thread(name="img", target=camera.find_objects, daemon=True)
    # Returns motor speeds needed to rotate to ball
    thread_game_logic = threading.Thread(name="auto",
                                         target=robot.autopilot,
                                         daemon=True)
    # Controls all the motors
    thread_mainboard_comm = threading.Thread(
        name="comm", target=mainboard.send_to_mainboard, daemon=True)
    # Manual control
    thread_manual_control = threading.Thread(name="manual",
                                             target=remote_control.gamepad,
                                             args=(mainboard, autonomy,
                                                   stop_flag),
                                             daemon=True)

    # Start the threads
    #thread_image_processing.start()
    thread_game_logic.start()
    thread_mainboard_comm.start()
    thread_manual_control.start()

    # The main loop for our program, use to display values etc
    while True:
        # Check for stop signals
        if stop_flag.is_set():

            #thread_image_processing.join()
            thread_game_logic.join()
            thread_mainboard_comm.join()
            thread_manual_control.join()

            print("Closing main.py..")
            return
Пример #4
0
                  author2, False, "res/hpGF.png")
book5 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat", author2,
                  False, "res/hpGF.png")
book6 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat", author2,
                  False, "res/hpGF.png")
book7 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat", author2,
                  False, "res/hpGF.png")
book8 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat", author2,
                  False, "res/hpGF.png")
book9 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat", author2,
                  False, "res/hpGF.png")
book10 = book.Book("Piter Pan", 210, 1111, 200, "Fantasy", "RusPechat",
                   author2, False, "res/hpGF.png")

#users
basket1 = basket.Basket()
user1 = user.User("admin", "admin", discount1.userDiscount, basket1,
                  "*****@*****.**", "Ivan Petrov", "res/ava.gif")

#local base
booksCollection = [
    book1, book2, book3, book4, book5, book6, book7, book8, book9, book10
]
booksCollection.sort(key=lambda i: i.name)
searchCollection = booksCollection
authenticated = False


class MainView(tk.Frame):
    def __init__(self, *args, **kwargs):
        tk.Frame.__init__(self, *args, **kwargs)
Пример #5
0

if __name__ == '__main__':
    # obtain audio from the microphone
    recognizer = sr.Recognizer()
    audio_source = sr.Microphone(sample_rate=16000)
    with audio_source as source:
        # sometimes it may be better to adjust automatically for ambient noise, sometimes it's not
        #recognizer.adjust_for_ambient_noise(source)
        recognizer.energy_threshold = 1000  # adjust this to your value

    # read settings
    settings = load_settings()
    wit_ai_key = settings.get(SETTINGS_WIT_AI_KEY)
    if wit_ai_key == None:
        print("No wit.ai key found, please enter wit.ai key now:")
        wit_ai_key = input()
        settings[SETTINGS_WIT_AI_KEY] = wit_ai_key
        save_settings(settings)

    print("Say something!")

    cobra = cobra.Cobra(recognizer, audio_source, get_polish_speaker,
                        basket.Basket(), wit_ai_key)
    cobra.daemon = True
    cobra.start()
    print("Cobra started, press ENTER to terminate")
    input()
    print("Requesting stop")
    cobra.stop()
    cobra.join()
Пример #6
0
        cx = 0
        sorted_contours = sorted(contours, key=cv2.contourArea)

        if len(sorted_contours) > 0:
            cv2.drawContours(frame, sorted_contours[-1], -1, (0, 255, 0), 3)

        try:
            if len(sorted_contours) > 0:
                # image moment
                m = cv2.moments(sorted_contours[-1])
                # print(m.keys())

                # The centroid point
                cx = int(m['m10'] / m['m00'])
                cy = int(m['m01'] / m['m00'])
                # print(cx)

                # for contour in contours:
                #     cv2.drawContours(frame, contour, -1, (0, 255, 0), 3)
        except:
            cx = 0

        return frame, cx


basket = basket.Basket("thresh/thresh_basket.txt")
balls = balls.Balls("thresh/thresh_ball.txt")
cam = Camera(basket, balls, 0)
while True:
    cam.find_objects()