Esempio n. 1
0
    if (pyray.check_collision_point_rec(touch_position, touch_area)
            and current_gesture != pyray.GESTURE_NONE):
        if current_gesture != last_gesture:
            gesture_strings.append(GESTURE_LABELS[current_gesture])

        # Reset gestures strings
        if len(gesture_strings) >= MAX_GESTURE_STRINGS:
            gesture_strings = []

    # Draw
    pyray.begin_drawing()

    pyray.clear_background(RAYWHITE)

    pyray.draw_rectangle_rec(touch_area, GRAY)
    pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30,
                         RAYWHITE)
    pyray.draw_text('GESTURES TEST AREA', SCREEN_WIDTH - 270,
                    SCREEN_HEIGHT - 40, 20, pyray.fade(GRAY, 0.5))

    for i, val in enumerate(gesture_strings):
        if i % 2 == 0:
            pyray.draw_rectangle(10, 30 + 20 * i, 200, 20,
                                 pyray.fade(LIGHTGRAY, 0.5))
        else:
            pyray.draw_rectangle(10, 30 + 20 * i, 200, 20,
                                 pyray.fade(LIGHTGRAY, 0.3))

        if i < len(gesture_strings) - 1:
            pyray.draw_text(val, 35, 36 + 20 * i, 10, DARKGRAY)
        else:
            pyray.draw_text(val, 35, 36 + 20 * i, 10, MAROON)
Esempio n. 2
0
box_position_y: int = SCREEN_HEIGHT // 2 - 40
scroll_speed = 4  # Scrolling speed in pixels

pyray.set_target_fps(60)  # Set our game to run at 60 frames-per-second


# Main game loop
while not pyray.window_should_close():  # Detect window close button or ESC key
    # Update
    box_position_y -= (pyray.get_mouse_wheel_move() * scroll_speed)

    # Draw
    pyray.begin_drawing()

    pyray.clear_background(RAYWHITE)

    pyray.draw_rectangle(
        SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, MAROON)

    pyray.draw_text('User mouse wheel to move the cube up and down!',
                    10, 10, 20, GRAY)
    pyray.draw_text('Box position Y: {:03d}'.format(box_position_y),
                    10, 40, 20, LIGHTGRAY)

    pyray.end_drawing()


# De-Initialization
pyray.close_window()  # Close window and OpenGL context