Exemplo n.º 1
0
        if count % 4 == 0:
            if codey.is_button('A'):
                music_lock = False
                axis_y -= 1
                down_lock = True
            else:
                down_lock = False
                if music_lock == False:
                    codey.say('jump.wav', False, None)
                    music_lock = True

        if game_status == GAME_PLAYING:
            if count % run_speed == 0 and (not down_lock):
                axis_y += 1

            if last_axis_y != axis_y:
                codey.pixel_off(7, last_axis_y)
                codey.pixel(7, axis_y)
            last_axis_y = axis_y

        if axis_y >= 7:
            axis_y = 7
        elif axis_y < 0:
            axis_y = 0
        game_over_check()
        time.sleep(0.01)
        count += 1


codey.on_start(on_start_callback)
Exemplo n.º 2
0
                t_count = 0
            t_count += 1
            time.sleep(0.020)


def button_a_cb():
    global plane_cur_pos
    global plane_last_pos
    plane_cur_pos -= 1
    if plane_cur_pos < 0:
        plane_cur_pos = 0


def button_b_cb():
    global plane_cur_pos
    global plane_last_pos
    plane_cur_pos += 1
    if plane_cur_pos > 13:
        plane_cur_pos = 13


codey.on_button("A", button_a_cb)
codey.on_button("B", button_b_cb)


def main_fun():
    plane_contril()


codey.on_start(main_fun)
def on_light_under_callback():
    global test_num
    test_num = 5
    codey.color("#ff0000", 0.2)
codey.on_light_under(10, on_light_under_callback)

def start_cb():
    global test_num
    test_num = 0
    codey.message(str('hello'))
    print("button and message test begin")
    while True:
        if test_num == 1:
            print("button_A event succeed")
            test_num = 0
        elif test_num == 2:
            print("button_B event succeed")
            test_num = 0
        elif test_num == 3:
            print("button_C event succeed")
            test_num = 0
        elif test_num == 4:
            print("message event succeed")
            test_num = 0
        if test_num == 5:
            print("light event succeed")
            test_num = 0

codey.on_start(start_cb)
Exemplo n.º 4
0
            a.rotate()
        if count % 2 == 0:
            b.rotate()
        if count % 15 == 0:
            down_flag = True
            c.show()

        if down_flag:
            c.down()
            if c.meet_border_check() == DOWN_MEET:
                c.hide()
                c.home()
                down_flag = False

        if codey.is_button('B'):
            p.right()
        elif codey.is_button('A'):
            p.left()

        if game.collision_check(p, a) or game.collision_check(
                p, b) or game.collision_check(p, c):
            codey.say("wrong")
            codey.color("#ff0000", 0.05)
            p.home()

        time.sleep(0.05)
        count += 1


codey.on_start(test)