Exemple #1
0
    DARKGRAY,
    MAROON,
    GRAY,
)

pyray = PyRay()

# Initialization
MAX_GESTURE_STRINGS = 20
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450

pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
                  'raylib [core] example - input gestures')

touch_position = pyray.Vector2(0, 0)
touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)

gesture_strings = []

current_gesture = pyray.GESTURE_NONE
last_gesture = pyray.GESTURE_NONE

GESTURE_LABELS = {
    pyray.GESTURE_TAP: 'GESTURE TAP',
    pyray.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP',
    pyray.GESTURE_HOLD: 'GESTURE HOLD',
    pyray.GESTURE_DRAG: 'GESTURE DRAG',
    pyray.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT',
    pyray.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT',
    pyray.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP',
Exemple #2
0
    DARKGRAY,
    MAROON,
    DARKBLUE,
    LIME,
)

pyray = PyRay()

# Initialization
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450

pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
                  'raylib [core] example - mouse input')

ball_position = pyray.Vector2(-100, -100)
ball_color = DARKBLUE

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
    ball_position = pyray.get_mouse_position()

    if pyray.is_mouse_button_pressed(pyray.MOUSE_LEFT_BUTTON):
        ball_color = MAROON
    elif pyray.is_mouse_button_pressed(pyray.MOUSE_MIDDLE_BUTTON):
        ball_color = LIME
    elif pyray.is_mouse_button_pressed(pyray.MOUSE_RIGHT_BUTTON):
        ball_color = DARKBLUE
Exemple #3
0
from raylib.pyray import PyRay
from raylib.colors import (
    RAYWHITE,
    DARKGRAY,
    MAROON,
)

pyray = PyRay()

# Initialization
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 450

pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
                  'raylib [core] example - keyboard input')
ball_position = pyray.Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)

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
    if pyray.is_key_down(pyray.KEY_RIGHT): ball_position.x += 2
    if pyray.is_key_down(pyray.KEY_LEFT): ball_position.x -= 2
    if pyray.is_key_down(pyray.KEY_UP): ball_position.y -= 2
    if pyray.is_key_down(pyray.KEY_DOWN): ball_position.y += 2

    # Draw
    pyray.begin_drawing()

    pyray.clear_background(RAYWHITE)