From a33f4fcc9aae5c8048cbd74d3e5723ea7f59b46d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 16 Nov 2024 20:11:08 +0000 Subject: [PATCH] update examples --- examples/audio/audio_module_playing.py | 51 +++------ examples/core/core_2d_camera.py | 10 +- examples/core/core_2d_camera_mouse_zoom.py | 7 +- examples/core/core_2d_camera_platformer.py | 10 +- .../core_3d_camera_first_person_incomplete.py | 18 ++-- .../core/core_3d_camera_free_incomplete.py | 2 +- examples/core/core_3d_camera_mode.py | 2 +- examples/core/core_basic_screen_manager.py | 6 +- examples/core/core_drop_files.py | 20 ++-- examples/core/core_input_gestures.py | 57 +++++----- examples/core/core_input_keys.py | 8 +- examples/core/core_input_mouse.py | 14 +-- examples/core/core_scissor_test.py | 2 +- .../core/core_smooth_pixel_perfect_camera.py | 4 +- examples/core/core_split_screen.py | 8 +- examples/core/core_vr_simulator.py | 21 ++-- examples/core/core_window_flags.py | 102 +++++++++--------- examples/core/core_window_should_close.py | 8 +- examples/extra/extra_camera.py | 2 +- examples/extra/extra_flow_field.py | 3 +- .../extra_transparent_undecorated_window.py | 6 +- examples/extra/textures_opencv.py | 4 +- examples/models/models_animation.py | 9 +- .../models_skybox_outdated_needs_update.py | 1 + examples/models/models_waving_cubes.py | 2 +- examples/others/rlgl_standalone.py | 10 +- examples/physics/physac.py | 16 ++- examples/shaders/light_system.py | 10 +- examples/shaders/shaders_basic_lighting.py | 2 +- examples/shaders/shaders_write_depth.py | 9 +- examples/shapes/shapes_basic_shapes.py | 43 +++----- examples/shapes/shapes_bouncing_ball.py | 2 +- ...hapes_draw_rounded_rectangle_incomplete.py | 21 ++-- examples/shapes/shapes_following_eyes.py | 8 +- examples/shapes/shapes_lines_bezier.py | 5 - examples/shapes/shapes_logo_raylib.py | 6 +- examples/textures/textures_bunnymark.py | 10 +- .../textures_bunnymark_more_pythonic.py | 4 +- examples/textures/textures_mouse_painting.py | 28 ++--- examples/textures/textures_to_image.py | 2 + 40 files changed, 232 insertions(+), 321 deletions(-) diff --git a/examples/audio/audio_module_playing.py b/examples/audio/audio_module_playing.py index e8694b1..94c7e25 100644 --- a/examples/audio/audio_module_playing.py +++ b/examples/audio/audio_module_playing.py @@ -6,26 +6,6 @@ raylib [audio] example - playing import dataclasses import pyray import raylib as rl -from raylib.colors import ( - RAYWHITE, - ORANGE, - RED, - GOLD, - LIME, - BLUE, - VIOLET, - BROWN, - LIGHTGRAY, - PINK, - YELLOW, - GREEN, - SKYBLUE, - PURPLE, - BEIGE, - MAROON, - GRAY, - BLACK -) MAX_CIRCLES=64 @@ -33,12 +13,11 @@ MAX_CIRCLES=64 @dataclasses.dataclass class CircleWave: - position: 'rl.Vector2' + position: pyray.Vector2 radius: float alpha: float speed: float - color: 'rl.Color' - + color: pyray.Color screenWidth = 800 screenHeight = 450 @@ -49,8 +28,8 @@ rl.InitWindow(screenWidth, screenHeight, b"raylib [audio] example - module playi rl.InitAudioDevice() # Initialize audio device -colors = [ ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, - YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE ] +colors = [pyray.ORANGE, pyray.RED, pyray.GOLD, pyray.LIME, pyray.BLUE, pyray.VIOLET, pyray.BROWN, pyray.LIGHTGRAY, pyray.PINK, + pyray.YELLOW, pyray.GREEN, pyray.SKYBLUE, pyray.PURPLE, pyray.BEIGE] # Creates some circles for visual effect circles = [] @@ -141,23 +120,23 @@ while not rl.WindowShouldClose(): # Detect window close button or ESC key #---------------------------------------------------------------------------------- pyray.begin_drawing() - pyray.clear_background(RAYWHITE) + pyray.clear_background(pyray.RAYWHITE) for i in range(MAX_CIRCLES): - pyray.draw_circle_v(circles[i].position, circles[i].radius, rl.Fade(circles[i].color, circles[i].alpha)) + pyray.draw_circle_v(circles[i].position, circles[i].radius, pyray.fade(circles[i].color, circles[i].alpha)) # Draw time bar - pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY) - pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, MAROON) - pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY) + pyray.draw_rectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.LIGHTGRAY) + pyray.draw_rectangle(20, screenHeight - 20 - 12, int(timePlayed), 12, pyray.MAROON) + pyray.draw_rectangle_lines(20, screenHeight - 20 - 12, screenWidth - 40, 12, pyray.GRAY) # Draw help instructions - pyray.draw_rectangle(20, 20, 425, 145, RAYWHITE) - pyray.draw_rectangle_lines(20, 20, 425, 145, GRAY) - pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, BLACK) - pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, BLACK) - pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, BLACK) - pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, MAROON) + pyray.draw_rectangle(20, 20, 425, 145, pyray.RAYWHITE) + pyray.draw_rectangle_lines(20, 20, 425, 145, pyray.GRAY) + pyray.draw_text("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, pyray.BLACK) + pyray.draw_text("PRESS P TO PAUSE/RESUME", 40, 70, 20, pyray.BLACK) + pyray.draw_text("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, pyray.BLACK) + pyray.draw_text(f"SPEED: {pitch}", 40, 130, 20, pyray.MAROON) pyray.end_drawing() #---------------------------------------------------------------------------------- diff --git a/examples/core/core_2d_camera.py b/examples/core/core_2d_camera.py index e95ea64..8a6bc05 100644 --- a/examples/core/core_2d_camera.py +++ b/examples/core/core_2d_camera.py @@ -57,18 +57,18 @@ while not pyray.window_should_close(): # Detect window close button or ESC key # Update # Player movement - if pyray.is_key_down(pyray.KEY_RIGHT): + if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT): player.x += 2 - elif pyray.is_key_down(pyray.KEY_LEFT): + elif pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT): player.x -= 2 # Camera target follows player camera.target = pyray.Vector2(player.x + 20, player.y + 20) # Camera rotation controls - if pyray.is_key_down(pyray.KEY_A): + if pyray.is_key_down(pyray.KeyboardKey.KEY_A): camera.rotation -= 1 - elif pyray.is_key_down(pyray.KEY_S): + elif pyray.is_key_down(pyray.KeyboardKey.KEY_S): camera.rotation += 1 # Limit camera rotation to 80 degrees (-40 to 40) @@ -86,7 +86,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key camera.zoom = 0.1 # Camera reset (zoom and rotation) - if pyray.is_key_pressed(pyray.KEY_R): + if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R): camera.zoom = 1.0 camera.rotation = 0.0 diff --git a/examples/core/core_2d_camera_mouse_zoom.py b/examples/core/core_2d_camera_mouse_zoom.py index ad4e1b9..aeeabf2 100644 --- a/examples/core/core_2d_camera_mouse_zoom.py +++ b/examples/core/core_2d_camera_mouse_zoom.py @@ -13,15 +13,14 @@ pyray.set_target_fps(60) camera = pyray.Camera2D() -camera = pyray.Camera2D() camera.zoom = 1.0 -pyray.set_target_fps(60); +pyray.set_target_fps(60) # main game loop while not pyray.window_should_close(): # update - if pyray.is_mouse_button_down(pyray.MOUSE_BUTTON_RIGHT): + if pyray.is_mouse_button_down(pyray.MouseButton.MOUSE_BUTTON_RIGHT): delta = pyray.get_mouse_delta() delta = pyray.vector2_scale(delta, -1.0 / camera.zoom) camera.target = pyray.vector2_add(camera.target, delta) @@ -58,7 +57,7 @@ while not pyray.window_should_close(): pyray.end_mode_2d() - pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE); + pyray.draw_text("Mouse right button drag to move, mouse wheel to zoom", 10, 10, 20, pyray.WHITE) pyray.end_drawing() diff --git a/examples/core/core_2d_camera_platformer.py b/examples/core/core_2d_camera_platformer.py index 35f4de9..db8ed8f 100644 --- a/examples/core/core_2d_camera_platformer.py +++ b/examples/core/core_2d_camera_platformer.py @@ -62,11 +62,11 @@ class EnvItem: def update_player(player, env_items, delta): - if pyray.is_key_down(pyray.KEY_LEFT): + if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT): player.position.x -= PLAYER_HOR_SPD * delta - if pyray.is_key_down(pyray.KEY_RIGHT): + if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT): player.position.x += PLAYER_HOR_SPD * delta - if pyray.is_key_down(pyray.KEY_SPACE) and player.can_jump: + if pyray.is_key_down(pyray.KeyboardKey.KEY_SPACE) and player.can_jump: player.speed = -PLAYER_JUMP_SPD player.can_jump = False @@ -264,11 +264,11 @@ while not pyray.window_should_close(): # Detect window close button or ESC key elif camera.zoom < 0.25: camera.zoom = 0.25 - if pyray.is_key_pressed(pyray.KEY_R): + if pyray.is_key_pressed(pyray.KeyboardKey.KEY_R): camera.zoom = 1.0 player.position = pyray.Vector2(400, 280) - if pyray.is_key_pressed(pyray.KEY_C): + if pyray.is_key_pressed(pyray.KeyboardKey.KEY_C): camera_option = (camera_option + 1) % camera_updaters_length # Call update camera function by its pointer diff --git a/examples/core/core_3d_camera_first_person_incomplete.py b/examples/core/core_3d_camera_first_person_incomplete.py index af8963b..743903b 100644 --- a/examples/core/core_3d_camera_first_person_incomplete.py +++ b/examples/core/core_3d_camera_first_person_incomplete.py @@ -10,7 +10,7 @@ MAX_COLUMNS = 20 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, b"raylib [core] example - 3d camera first person") +pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - 3d camera first person") # Define the camera to look into our 3d world (position, target, up vector) camera = pyray.Camera3D() @@ -18,24 +18,24 @@ camera.position = pyray.Vector3(4.0, 2.0, 4.0) camera.target = pyray.Vector3(0.0, 1.8, 0.0) camera.up = pyray.Vector3(0.0, 1.0, 0.0) camera.fovy = 60.0 -camera.projection = pyray.CAMERA_PERSPECTIVE +camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Generates some random columns -heights = [None] * MAX_COLUMNS -positions = [None] * MAX_COLUMNS -colors = [None] * MAX_COLUMNS +heights = [] +positions = [] +colors = [] for i in range(MAX_COLUMNS): - heights[i] = pyray.get_random_value(1, 12) * 1.0 - positions[i] = pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0) - colors[i] = pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255) + heights.append(pyray.get_random_value(1, 12) * 1.0) + positions.append(pyray.Vector3(pyray.get_random_value(-15, 15) * 1.0, heights[i]/2.0 * 1.0, pyray.get_random_value(-15, 15) * 1.0)) + colors.append(pyray.Color(pyray.get_random_value(20, 255), pyray.get_random_value(10, 55), 30, 255)) pyray.set_target_fps(60) while not pyray.window_should_close(): - pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON) + pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON) pyray.begin_drawing() diff --git a/examples/core/core_3d_camera_free_incomplete.py b/examples/core/core_3d_camera_free_incomplete.py index 2ae7db0..a1e54ce 100644 --- a/examples/core/core_3d_camera_free_incomplete.py +++ b/examples/core/core_3d_camera_free_incomplete.py @@ -25,7 +25,7 @@ while not window_should_close(): # Detect window close button or ESC key # Update update_camera(camera, CameraMode.CAMERA_FREE) - if is_key_pressed(KEY_Z): + if is_key_pressed(KeyboardKey.KEY_Z): camera.target = Vector3(0.0, 0.0, 0.0) # Draw diff --git a/examples/core/core_3d_camera_mode.py b/examples/core/core_3d_camera_mode.py index 79b7b63..715660c 100644 --- a/examples/core/core_3d_camera_mode.py +++ b/examples/core/core_3d_camera_mode.py @@ -40,7 +40,7 @@ while not pyray.window_should_close(): pyray.end_mode_3d() - pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY); + pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY) pyray.draw_fps(10, 10) diff --git a/examples/core/core_basic_screen_manager.py b/examples/core/core_basic_screen_manager.py index fbe473e..5f3eb09 100644 --- a/examples/core/core_basic_screen_manager.py +++ b/examples/core/core_basic_screen_manager.py @@ -27,13 +27,13 @@ def main(): if frame_count > 120: current_screen = GameScreen.TITLE elif current_screen == GameScreen.TITLE: - if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): + if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP): current_screen = GameScreen.GAMEPLAY elif current_screen == GameScreen.GAMEPLAY: - if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): + if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP): current_screen = GameScreen.ENDING elif current_screen == GameScreen.ENDING: - if is_key_pressed(KEY_ENTER) or is_gesture_detected(GESTURE_TAP): + if is_key_pressed(KeyboardKey.KEY_ENTER) or is_gesture_detected(Gesture.GESTURE_TAP): current_screen = GameScreen.TITLE begin_drawing() diff --git a/examples/core/core_drop_files.py b/examples/core/core_drop_files.py index d55e4d3..d627442 100644 --- a/examples/core/core_drop_files.py +++ b/examples/core/core_drop_files.py @@ -11,12 +11,6 @@ """ import pyray -from raylib.colors import ( - RAYWHITE, - DARKGRAY, - LIGHTGRAY, - GRAY -) screenWidth = 800 screenHeight = 450 @@ -36,21 +30,21 @@ while not pyray.window_should_close(): pyray.begin_drawing() - pyray.clear_background(RAYWHITE) + pyray.clear_background(pyray.RAYWHITE) if droppedFiles.count == 0: - pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY) + pyray.draw_text("Drop your files to this window!", 100, 40, 20, pyray.DARKGRAY) else: - pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY) + pyray.draw_text("Dropped files:", 100, 40, 20, pyray.DARKGRAY) for i in range(0, droppedFiles.count): if i % 2 == 0: - pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5)) + pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.5)) else: - pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3)) - pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY) + pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(pyray.LIGHTGRAY, 0.3)) + pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, pyray.GRAY) - pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY) + pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, pyray.DARKGRAY) pyray.end_drawing() # De-Initialization diff --git a/examples/core/core_input_gestures.py b/examples/core/core_input_gestures.py index 86024ab..8d5bff5 100644 --- a/examples/core/core_input_gestures.py +++ b/examples/core/core_input_gestures.py @@ -4,13 +4,6 @@ raylib [core] example - Input Gestures Detection """ import pyray -from raylib.colors import ( - RAYWHITE, - LIGHTGRAY, - DARKGRAY, - MAROON, - GRAY, -) @@ -26,20 +19,20 @@ touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20) gesture_strings = [] -current_gesture = pyray.GESTURE_NONE -last_gesture = pyray.GESTURE_NONE +current_gesture = pyray.Gesture.GESTURE_NONE +last_gesture = pyray.Gesture.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', - pyray.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN', - pyray.GESTURE_PINCH_IN: 'GESTURE PINCH IN', - pyray.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT', + pyray.Gesture.GESTURE_TAP: 'GESTURE TAP', + pyray.Gesture.GESTURE_DOUBLETAP: 'GESTURE DOUBLETAP', + pyray.Gesture.GESTURE_HOLD: 'GESTURE HOLD', + pyray.Gesture.GESTURE_DRAG: 'GESTURE DRAG', + pyray.Gesture.GESTURE_SWIPE_RIGHT: 'GESTURE SWIPE RIGHT', + pyray.Gesture.GESTURE_SWIPE_LEFT: 'GESTURE SWIPE LEFT', + pyray.Gesture.GESTURE_SWIPE_UP: 'GESTURE SWIPE UP', + pyray.Gesture.GESTURE_SWIPE_DOWN: 'GESTURE SWIPE DOWN', + pyray.Gesture.GESTURE_PINCH_IN: 'GESTURE PINCH IN', + pyray.Gesture.GESTURE_PINCH_OUT: 'GESTURE PINCH OUT', } pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second @@ -54,7 +47,7 @@ while not pyray.window_should_close(): # Detect window close button or ESC key if ( pyray.check_collision_point_rec(touch_position, touch_area) - and current_gesture != pyray.GESTURE_NONE + and current_gesture != pyray.Gesture.GESTURE_NONE ): if current_gesture != last_gesture: gesture_strings.append(GESTURE_LABELS[current_gesture]) @@ -66,34 +59,34 @@ while not pyray.window_should_close(): # Detect window close button or ESC key # Draw pyray.begin_drawing() - pyray.clear_background(RAYWHITE) + pyray.clear_background(pyray.RAYWHITE) - pyray.draw_rectangle_rec(touch_area, GRAY) + pyray.draw_rectangle_rec(touch_area, pyray.GRAY) pyray.draw_rectangle(225, 15, SCREEN_WIDTH - 240, SCREEN_HEIGHT - 30, - RAYWHITE) + pyray.RAYWHITE) pyray.draw_text( 'GESTURES TEST AREA', - SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(GRAY, 0.5) + SCREEN_WIDTH - 270, SCREEN_HEIGHT - 40, 20, pyray.fade(pyray.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)) + 10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.5)) else: pyray.draw_rectangle( - 10, 30 + 20 * i, 200, 20, pyray.fade(LIGHTGRAY, 0.3)) + 10, 30 + 20 * i, 200, 20, pyray.fade(pyray.LIGHTGRAY, 0.3)) if i < len(gesture_strings) - 1: - pyray.draw_text(val, 35, 36 + 20 * i, 10, DARKGRAY) + pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.DARKGRAY) else: - pyray.draw_text(val, 35, 36 + 20 * i, 10, MAROON) + pyray.draw_text(val, 35, 36 + 20 * i, 10, pyray.MAROON) - pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, GRAY) - pyray.draw_text('DETECTED GESTURES', 50, 15, 10, GRAY) + pyray.draw_rectangle_lines(10, 29, 200, SCREEN_HEIGHT - 50, pyray.GRAY) + pyray.draw_text('DETECTED GESTURES', 50, 15, 10, pyray.GRAY) - if current_gesture != pyray.GESTURE_NONE: - pyray.draw_circle_v(touch_position, 30, MAROON) + if current_gesture != pyray.Gesture.GESTURE_NONE: + pyray.draw_circle_v(touch_position, 30, pyray.MAROON) pyray.end_drawing() diff --git a/examples/core/core_input_keys.py b/examples/core/core_input_keys.py index 4c57544..8635ee6 100644 --- a/examples/core/core_input_keys.py +++ b/examples/core/core_input_keys.py @@ -19,13 +19,13 @@ 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): + if pyray.is_key_down(pyray.KeyboardKey.KEY_RIGHT): ball_position.x += 2 - if pyray.is_key_down(pyray.KEY_LEFT): + if pyray.is_key_down(pyray.KeyboardKey.KEY_LEFT): ball_position.x -= 2 - if pyray.is_key_down(pyray.KEY_UP): + if pyray.is_key_down(pyray.KeyboardKey.KEY_UP): ball_position.y -= 2 - if pyray.is_key_down(pyray.KEY_DOWN): + if pyray.is_key_down(pyray.KeyboardKey.KEY_DOWN): ball_position.y += 2 # Draw diff --git a/examples/core/core_input_mouse.py b/examples/core/core_input_mouse.py index bea22e5..5f1cce9 100644 --- a/examples/core/core_input_mouse.py +++ b/examples/core/core_input_mouse.py @@ -22,19 +22,19 @@ while not window_should_close(): # Detect window close button or ESC key # Update ball_position = get_mouse_position() - if is_mouse_button_pressed(MOUSE_BUTTON_LEFT): + if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT): ball_color = MAROON - elif is_mouse_button_pressed(MOUSE_BUTTON_MIDDLE): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_MIDDLE): ball_color = LIME - elif is_mouse_button_pressed(MOUSE_BUTTON_RIGHT): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_RIGHT): ball_color = DARKBLUE - elif is_mouse_button_pressed(MOUSE_BUTTON_SIDE): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_SIDE): ball_color = PURPLE - elif is_mouse_button_pressed(MOUSE_BUTTON_EXTRA): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_EXTRA): ball_color = YELLOW - elif is_mouse_button_pressed(MOUSE_BUTTON_FORWARD): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_FORWARD): ball_color = ORANGE - elif is_mouse_button_pressed(MOUSE_BUTTON_BACK): + elif is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_BACK): ball_color = BEIGE # Draw begin_drawing() diff --git a/examples/core/core_scissor_test.py b/examples/core/core_scissor_test.py index c2e43ad..e54b214 100644 --- a/examples/core/core_scissor_test.py +++ b/examples/core/core_scissor_test.py @@ -23,7 +23,7 @@ set_target_fps(60) # Set our game to run at 60 frames-per-second while not window_should_close(): # Detect window close button or ESC key # Update # ---------------------------------------------------------------------------------- - if is_key_pressed(KEY_S): + if is_key_pressed(KeyboardKey.KEY_S): scissorMode = not scissorMode # Centre the scissor area around the mouse position diff --git a/examples/core/core_smooth_pixel_perfect_camera.py b/examples/core/core_smooth_pixel_perfect_camera.py index 1dcdc67..fdf0604 100644 --- a/examples/core/core_smooth_pixel_perfect_camera.py +++ b/examples/core/core_smooth_pixel_perfect_camera.py @@ -18,7 +18,7 @@ worldSpaceCamera.zoom = 1.0 screenSpaceCamera = Camera2D([0]) # Smoothing camera screenSpaceCamera.zoom = 1.0 -target = load_render_texture(virtualScreenWidth, virtualScreenHeight); # This is where we'll draw all our objects. +target = load_render_texture(virtualScreenWidth, virtualScreenHeight) # This is where we'll draw all our objects. rec01 = Rectangle(70.0, 35.0, 20.0, 20.0) rec02 = Rectangle(90.0, 55.0, 30.0, 10.0) @@ -42,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key # Update - rotation += 60.0 *get_frame_time(); # Rotate the rectangles, 60 degrees per second + rotation += 60.0 *get_frame_time() # Rotate the rectangles, 60 degrees per second # Make the camera move to demonstrate the effect cameraX = (math.sin(get_time())*50.0) - 10.0 diff --git a/examples/core/core_split_screen.py b/examples/core/core_split_screen.py index a6961f2..71b5640 100644 --- a/examples/core/core_split_screen.py +++ b/examples/core/core_split_screen.py @@ -66,21 +66,21 @@ while not window_should_close(): # Detect window close button or ESC key # Move Player1 forward and backwards (no turning) - if is_key_down(KEY_W): + if is_key_down(KeyboardKey.KEY_W): cameraPlayer1.position.z += offsetThisFrame cameraPlayer1.target.z += offsetThisFrame - elif is_key_down(KEY_S): + elif is_key_down(KeyboardKey.KEY_S): cameraPlayer1.position.z -= offsetThisFrame cameraPlayer1.target.z -= offsetThisFrame # Move Player2 forward and backwards (no turning) - if is_key_down(KEY_UP): + if is_key_down(KeyboardKey.KEY_UP): cameraPlayer2.position.x += offsetThisFrame cameraPlayer2.target.x += offsetThisFrame - elif is_key_down(KEY_DOWN): + elif is_key_down(KeyboardKey.KEY_DOWN): cameraPlayer2.position cameraPlayer2.position.x -= offsetThisFrame cameraPlayer2.target.x -= offsetThisFrame diff --git a/examples/core/core_vr_simulator.py b/examples/core/core_vr_simulator.py index 59a4a61..10573f2 100644 --- a/examples/core/core_vr_simulator.py +++ b/examples/core/core_vr_simulator.py @@ -17,7 +17,6 @@ device = pyray.VrDeviceInfo( 1200, # Vertical resolution in pixels 0.133793, # Horizontal size in meters 0.0669, # Vertical size in meters - 0.04678, # Screen center in meters 0.041, # Distance between eye and display in meters 0.07, # Lens separation distance in meters 0.07, # IPD (distance between pupils) in meters @@ -35,15 +34,15 @@ config = pyray.load_vr_stereo_config(device) distortion = pyray.load_shader(pyray.ffi.NULL, f"resources/distortion{GLSL_VERSION}.fs") # Update distortion shader with lens and distortion-scale parameters -pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 2, pyray.ffi.new('char []', b"leftLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightLensCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"leftScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"rightScreenCenter"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.SHADER_UNIFORM_VEC2) -pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.SHADER_UNIFORM_VEC4) -pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.SHADER_UNIFORM_VEC4) +pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scale"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 2,pyray.ffi.new('char []', b"scaleIn"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC2) +pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"deviceWarpParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4) +pyray.set_shader_value(distortion, 4,pyray.ffi.new('char []', b"chromaAbParam"), pyray.ShaderUniformDataType.SHADER_UNIFORM_VEC4) # Initialize framebuffer for stereo rendering # NOTE: Screen size should match HMD aspect ratio @@ -59,7 +58,7 @@ camera = pyray.Camera3D( pyray.Vector3(0.0, 2.0, 0.0), # Camera looking at point pyray.Vector3(0.0, 1.0, 0.0), # Camera up vector 60.0, # Camera field-of-view Y - pyray.CAMERA_PERSPECTIVE # Camera projection type + pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type ) cubePosition = pyray.Vector3(0.0, 0.0, 0.0) @@ -71,7 +70,7 @@ pyray.set_target_fps(90) # Set our game to run at 90 frames-per-sec # Main game loop while not pyray.window_should_close(): # Detect window close button or ESC key # Update - pyray.update_camera(camera, pyray.CAMERA_FIRST_PERSON) + pyray.update_camera(camera, pyray.CameraMode.CAMERA_FIRST_PERSON) # Draw pyray.begin_texture_mode(target) diff --git a/examples/core/core_window_flags.py b/examples/core/core_window_flags.py index 89e5321..14569fe 100644 --- a/examples/core/core_window_flags.py +++ b/examples/core/core_window_flags.py @@ -6,7 +6,7 @@ import pyray screen_width = 800 screen_height = 450 -init_window(screen_width, screen_height, b"raylib [core] example - window flags") +init_window(screen_width, screen_height, "raylib [core] example - window flags") ball_position = Vector2(get_screen_width() / 2.0, get_screen_height() / 2.0) ball_speed = Vector2(5.0, 4.0) @@ -18,71 +18,71 @@ frames_counter = 0 while not window_should_close(): # Detect window close button or ESC key # Update # ----------------------------------------------------- - if is_key_pressed(pyray.KEY_F): + if is_key_pressed(pyray.KeyboardKey.KEY_F): toggle_fullscreen() - if is_key_pressed(pyray.KEY_R): - if is_window_state(pyray.FLAG_WINDOW_RESIZABLE): - clear_window_state(pyray.FLAG_WINDOW_RESIZABLE) + if is_key_pressed(pyray.KeyboardKey.KEY_R): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE): + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE) else: - set_window_state(pyray.FLAG_WINDOW_RESIZABLE) + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE) - if is_key_pressed(pyray.KEY_D): - if is_window_state(pyray.FLAG_WINDOW_UNDECORATED): - clear_window_state(pyray.FLAG_WINDOW_UNDECORATED) + if is_key_pressed(pyray.KeyboardKey.KEY_D): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED): + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED) else: - set_window_state(pyray.FLAG_WINDOW_UNDECORATED) + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED) - if is_key_pressed(pyray.KEY_H): - if not is_window_state(pyray.FLAG_WINDOW_HIDDEN): - set_window_state(pyray.FLAG_WINDOW_HIDDEN) + if is_key_pressed(pyray.KeyboardKey.KEY_H): + if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN): + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN) frames_counter = 0 - if is_window_state(pyray.FLAG_WINDOW_HIDDEN): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN): frames_counter += 1 if frames_counter >= 240: - clear_window_state(pyray.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIDDEN) # Show window after 3 seconds - if is_key_pressed(pyray.KEY_N): - if not is_window_state(pyray.FLAG_WINDOW_MINIMIZED): + if is_key_pressed(pyray.KeyboardKey.KEY_N): + if not is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED): minimize_window() frames_counter = 0 - if is_window_state(pyray.FLAG_WINDOW_MINIMIZED): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED): frames_counter += 1 if frames_counter >= 240: restore_window() # Restore window after 3 seconds - if is_key_pressed(pyray.KEY_M): - if is_window_state(pyray.FLAG_WINDOW_RESIZABLE): - if is_window_state(pyray.FLAG_WINDOW_MAXIMIZED): + if is_key_pressed(pyray.KeyboardKey.KEY_M): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED): restore_window() else: maximize_window() - if is_key_pressed(pyray.KEY_U): - if is_window_state(pyray.FLAG_WINDOW_UNFOCUSED): - clear_window_state(pyray.FLAG_WINDOW_UNFOCUSED) + if is_key_pressed(pyray.KeyboardKey.KEY_U): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED): + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED) else: - set_window_state(pyray.FLAG_WINDOW_UNFOCUSED) + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED) - if is_key_pressed(pyray.KEY_T): - if is_window_state(pyray.FLAG_WINDOW_TOPMOST): - clear_window_state(pyray.FLAG_WINDOW_TOPMOST) + if is_key_pressed(pyray.KeyboardKey.KEY_T): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST): + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST) else: - set_window_state(pyray.FLAG_WINDOW_TOPMOST) + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_TOPMOST) - if is_key_pressed(pyray.KEY_A): - if is_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN): - clear_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN) + if is_key_pressed(pyray.KeyboardKey.KEY_A): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN): + clear_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN) else: - set_window_state(pyray.FLAG_WINDOW_ALWAYS_RUN) + set_window_state(pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN) - if is_key_pressed(pyray.KEY_V): - if is_window_state(pyray.FLAG_VSYNC_HINT): - clear_window_state(pyray.FLAG_VSYNC_HINT) + if is_key_pressed(pyray.KeyboardKey.KEY_V): + if is_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT): + clear_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT) else: - set_window_state(pyray.FLAG_VSYNC_HINT) + set_window_state(pyray.ConfigFlags.FLAG_VSYNC_HINT) # Bouncing ball logic ball_position.x += ball_speed.x @@ -96,7 +96,7 @@ while not window_should_close(): # Detect window close button or ESC key # ----------------------------------------------------- begin_drawing() - if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT): clear_background(BLANK) else: clear_background(RAYWHITE) @@ -113,16 +113,16 @@ while not window_should_close(): # Detect window close button or ESC key # Draw window state info draw_text("Following flags can be set after window creation:", 10, 60, 10, GRAY) flag_texts = [ - ("FLAG_FULLSCREEN_MODE", pyray.FLAG_FULLSCREEN_MODE), - ("FLAG_WINDOW_RESIZABLE", pyray.FLAG_WINDOW_RESIZABLE), - ("FLAG_WINDOW_UNDECORATED", pyray.FLAG_WINDOW_UNDECORATED), - ("FLAG_WINDOW_HIDDEN", pyray.FLAG_WINDOW_HIDDEN), - ("FLAG_WINDOW_MINIMIZED", pyray.FLAG_WINDOW_MINIMIZED), - ("FLAG_WINDOW_MAXIMIZED", pyray.FLAG_WINDOW_MAXIMIZED), - ("FLAG_WINDOW_UNFOCUSED", pyray.FLAG_WINDOW_UNFOCUSED), - ("FLAG_WINDOW_TOPMOST", pyray.FLAG_WINDOW_TOPMOST), - ("FLAG_WINDOW_ALWAYS_RUN", pyray.FLAG_WINDOW_ALWAYS_RUN), - ("FLAG_VSYNC_HINT", pyray.FLAG_VSYNC_HINT), + ("FLAG_FULLSCREEN_MODE", pyray.ConfigFlags.FLAG_FULLSCREEN_MODE), + ("FLAG_WINDOW_RESIZABLE", pyray.ConfigFlags.FLAG_WINDOW_RESIZABLE), + ("FLAG_WINDOW_UNDECORATED", pyray.ConfigFlags.FLAG_WINDOW_UNDECORATED), + ("FLAG_WINDOW_HIDDEN", pyray.ConfigFlags.FLAG_WINDOW_HIDDEN), + ("FLAG_WINDOW_MINIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MINIMIZED), + ("FLAG_WINDOW_MAXIMIZED", pyray.ConfigFlags.FLAG_WINDOW_MAXIMIZED), + ("FLAG_WINDOW_UNFOCUSED", pyray.ConfigFlags.FLAG_WINDOW_UNFOCUSED), + ("FLAG_WINDOW_TOPMOST", pyray.ConfigFlags.FLAG_WINDOW_TOPMOST), + ("FLAG_WINDOW_ALWAYS_RUN", pyray.ConfigFlags.FLAG_WINDOW_ALWAYS_RUN), + ("FLAG_VSYNC_HINT", pyray.ConfigFlags.FLAG_VSYNC_HINT), ] y_offset = 80 for text, flag in flag_texts: @@ -133,15 +133,15 @@ while not window_should_close(): # Detect window close button or ESC key y_offset += 20 draw_text("Following flags can only be set before window creation:", 10, 300, 10, GRAY) - if is_window_state(pyray.FLAG_WINDOW_HIGHDPI): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_HIGHDPI): draw_text("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME) else: draw_text("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON) - if is_window_state(pyray.FLAG_WINDOW_TRANSPARENT): + if is_window_state(pyray.ConfigFlags.FLAG_WINDOW_TRANSPARENT): draw_text("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME) else: draw_text("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON) - if is_window_state(pyray.FLAG_MSAA_4X_HINT): + if is_window_state(pyray.ConfigFlags.FLAG_MSAA_4X_HINT): draw_text("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME) else: draw_text("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON) diff --git a/examples/core/core_window_should_close.py b/examples/core/core_window_should_close.py index aecebe4..a02d493 100644 --- a/examples/core/core_window_should_close.py +++ b/examples/core/core_window_should_close.py @@ -12,7 +12,7 @@ SCREEN_HEIGHT = 450 init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - window should close") -set_exit_key(KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works +set_exit_key(KeyboardKey.KEY_NULL) # Disable KEY_ESCAPE to close window, X-button still works exitWindowRequested = False # Flag to request window to exit exitWindow = False # Flag to set window to exit @@ -26,7 +26,7 @@ while not exitWindow: # Update # ---------------------------------------------------------------------------------- # Detect if X-button or KEY_ESCAPE have been pressed to close window - if window_should_close() or is_key_pressed(KEY_ESCAPE): + if window_should_close() or is_key_pressed(KeyboardKey.KEY_ESCAPE): exitWindowRequested = True if exitWindowRequested: @@ -34,9 +34,9 @@ while not exitWindow: # A request for close window has been issued, we can save data before closing # or just show a message asking for confirmation - if is_key_pressed(KEY_Y): + if is_key_pressed(KeyboardKey.KEY_Y): exitWindow = True - elif is_key_pressed(KEY_N): + elif is_key_pressed(KeyboardKey.KEY_N): exitWindowRequested = False # ---------------------------------------------------------------------------------- diff --git a/examples/extra/extra_camera.py b/examples/extra/extra_camera.py index c02a821..e1fcb0b 100644 --- a/examples/extra/extra_camera.py +++ b/examples/extra/extra_camera.py @@ -1,7 +1,7 @@ # python3 -m pip install pyglm from math import sin, cos -import glm +import glm # type: ignore from raylib import rl, ffi diff --git a/examples/extra/extra_flow_field.py b/examples/extra/extra_flow_field.py index b9ef93e..7f88117 100644 --- a/examples/extra/extra_flow_field.py +++ b/examples/extra/extra_flow_field.py @@ -8,7 +8,8 @@ python3 flow-field """ import sys, math, time, random -import glm # Note package is PyGLM, not glm. +import glm # type: ignore +# Note package is PyGLM, not glm. from raylib import rl, ffi from raylib.colors import * diff --git a/examples/extra/extra_transparent_undecorated_window.py b/examples/extra/extra_transparent_undecorated_window.py index c0cef5f..3c5895a 100644 --- a/examples/extra/extra_transparent_undecorated_window.py +++ b/examples/extra/extra_transparent_undecorated_window.py @@ -18,9 +18,9 @@ Mac: """ import sys, time -import glm -import pytweening as tween -import screeninfo +import glm # type: ignore +import pytweening as tween # type: ignore +import screeninfo # type: ignore from raylib import rl, ffi from raylib.colors import * diff --git a/examples/extra/textures_opencv.py b/examples/extra/textures_opencv.py index f09e965..4edea98 100644 --- a/examples/extra/textures_opencv.py +++ b/examples/extra/textures_opencv.py @@ -1,4 +1,4 @@ -import cv2 as cv +import cv2 as cv # type:ignore from pyray import * opencv_image = cv.imread("resources/raylib_logo.jpg") @@ -10,7 +10,7 @@ screenHeight = 450 init_window(screenWidth, screenHeight, "example - image loading") pointer_to_image_data = ffi.from_buffer(opencv_image.data) -raylib_image = Image(pointer_to_image_data, 256, 256, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8) +raylib_image = Image(pointer_to_image_data, 256, 256, 1, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8) texture = load_texture_from_image(raylib_image) unload_image(raylib_image) diff --git a/examples/models/models_animation.py b/examples/models/models_animation.py index 9cd5710..9b40722 100644 --- a/examples/models/models_animation.py +++ b/examples/models/models_animation.py @@ -1,4 +1,3 @@ - import pyray as ray @@ -13,11 +12,11 @@ camera.position = ray.Vector3( 10.0, 10.0, 10.0 ) # Camera position camera.target = ray.Vector3( 0.0, 0.0, 0.0 ) # Camera looking at point camera.up = ray.Vector3( 0.0, 1.0, 0.0 ) # Camera up vector (rotation towards target) camera.fovy = 45.0 # Camera field-of-view Y -camera.projection = ray.CAMERA_PERSPECTIVE # Camera mode type +camera.projection = ray.CameraProjection.CAMERA_PERSPECTIVE # Camera mode type model = ray.load_model("resources/models/iqm/guy.iqm") # Load the animated model mesh and basic data texture = ray.load_texture("resources/models/iqm/guytex.png") # Load model texture and set material -ray.set_material_texture(model.materials, ray.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture +ray.set_material_texture(model.materials, ray.MaterialMapIndex.MATERIAL_MAP_ALBEDO, texture) # Set model material map texture position = ( 0., 0., 0. ) # Set model position @@ -33,10 +32,10 @@ ray.set_target_fps(60) # Set our game to run at 60 frames-per- while not ray.window_should_close(): # Detect window close button or ESC key # Update #---------------------------------------------------------------------------------- - ray.update_camera(camera, ray.CAMERA_FREE) + ray.update_camera(camera, ray.CameraMode.CAMERA_FREE) # Play animation when spacebar is held down - if ray.is_key_down(ray.KEY_SPACE): + if ray.is_key_down(ray.KeyboardKey.KEY_SPACE): anim_frame_counter+=1 ray.update_model_animation(model, anims[0], anim_frame_counter) if anim_frame_counter >= anims[0].frameCount: diff --git a/examples/models/models_skybox_outdated_needs_update.py b/examples/models/models_skybox_outdated_needs_update.py index a3dc441..5f193b7 100644 --- a/examples/models/models_skybox_outdated_needs_update.py +++ b/examples/models/models_skybox_outdated_needs_update.py @@ -1,3 +1,4 @@ +#type: ignore import raylib as rl from raylib.colors import * diff --git a/examples/models/models_waving_cubes.py b/examples/models/models_waving_cubes.py index a5b803a..af14105 100644 --- a/examples/models/models_waving_cubes.py +++ b/examples/models/models_waving_cubes.py @@ -15,7 +15,7 @@ camera.position = Vector3(30.0, 20.0, 30.0) # Camera position camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target) camera.fovy = 70.0 # Camera field-of-view Y -camera.projection = pyray.CAMERA_PERSPECTIVE # Camera projection type +camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera projection type # Specify the amount of blocks in each direction numBlocks = 15 diff --git a/examples/others/rlgl_standalone.py b/examples/others/rlgl_standalone.py index 29274ee..0332b5a 100644 --- a/examples/others/rlgl_standalone.py +++ b/examples/others/rlgl_standalone.py @@ -118,18 +118,18 @@ class Camera: # GLFW3: Error callback @ffi.callback("void(int, const char *)") def ErrorCallback(error: int, description: bytes): - print("%s" % description, file=sys.stderr) + print("%r" % description, file=sys.stderr) # GLFW3: Keyboard callback @ffi.callback("void(GLFWwindow *, int, int, int, int)") -def KeyCallback(window: 'GLFWwindow', key: int, scancode: int, action: int, mods: int): +def KeyCallback(window, key: int, scancode: int, action: int, mods: int): if key == GLFW_KEY_ESCAPE and action == GLFW_PRESS: rl.glfwSetWindowShouldClose(window, GLFW_TRUE) # Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally) -def DrawRectangleV(position: 'raylib.Vector2', size: 'raylib.Vector2', color: Color): +def DrawRectangleV(position, size, color: Color): rl.rlBegin(RL_TRIANGLES) rl.rlColor4ub(color.r, color.g, color.b, color.a) rl.rlVertex2f(position.x, position.y) @@ -168,7 +168,7 @@ def DrawGrid(slices: int, spacing: float): # Draw cube # NOTE: Cube position is the center position -def DrawCube(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color): +def DrawCube(position, width: float, height: float, length: float, color: Color): x: float = 0.0 y: float = 0.0 z: float = 0.0 @@ -242,7 +242,7 @@ def DrawCube(position: 'raylib.Vector3', width: float, height: float, length: fl #Draw cube wires -def DrawCubeWires(position: 'raylib.Vector3', width: float, height: float, length: float, color: Color): +def DrawCubeWires(position, width: float, height: float, length: float, color: Color): x: float = 0.0 y: float = 0.0 z: float = 0.0 diff --git a/examples/physics/physac.py b/examples/physics/physac.py index dd36765..e2ec815 100644 --- a/examples/physics/physac.py +++ b/examples/physics/physac.py @@ -2,13 +2,9 @@ raylib [physac] example - physics demo """ -from pyray import Vector2 + from raylib import * -from raylib.colors import ( - BLACK, - GREEN, - WHITE -) + SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 @@ -18,10 +14,10 @@ InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, b'[physac] Basic demo') InitPhysics() -floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) +floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) floor.enabled = False -circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) +circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) circle.enabled = False SetTargetFPS(60) @@ -34,10 +30,10 @@ while not WindowShouldClose(): if IsKeyPressed(KEY_R): # Reset physics system ResetPhysics() - floor = CreatePhysicsBodyRectangle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) + floor = CreatePhysicsBodyRectangle((SCREEN_WIDTH/2, SCREEN_HEIGHT), 500, 100, 10) floor.enabled = False - circle = CreatePhysicsBodyCircle(Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) + circle = CreatePhysicsBodyCircle((SCREEN_WIDTH/2, SCREEN_HEIGHT/2), 45, 10) circle.enabled = False # Physics body creation inputs diff --git a/examples/shaders/light_system.py b/examples/shaders/light_system.py index e43b889..f07e483 100644 --- a/examples/shaders/light_system.py +++ b/examples/shaders/light_system.py @@ -4,20 +4,20 @@ import raylib as rl class LightSystem: MAX_LIGHTS = 4 #// Max dynamic lights supported by shader lightsCount = 0 - lights = [] + lights: list['Light'] = [] def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls): self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs", b"resources/shaders/fogLight.fs"); #// Get some shader loactions - self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel"); - self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos"); + self.shader.locs[rl.SHADER_LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel") + self.shader.locs[rl.SHADER_LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos") #// ambient light level - self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient"); + self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient") v = rl.ffi.new("struct Vector4 *", ambient) - rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4); + rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.SHADER_UNIFORM_VEC4) for light in ls: self.add(light) diff --git a/examples/shaders/shaders_basic_lighting.py b/examples/shaders/shaders_basic_lighting.py index ee03684..101c345 100755 --- a/examples/shaders/shaders_basic_lighting.py +++ b/examples/shaders/shaders_basic_lighting.py @@ -48,7 +48,7 @@ screenWidth = 1200 screenHeight = 720 rl.SetConfigFlags( - rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE); # Enable Multi Sampling Anti Aliasing 4x (if available) + rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE) # Enable Multi Sampling Anti Aliasing 4x (if available) rl.InitWindow(screenWidth, screenHeight, b"raylib [shaders] example - basic lighting") camera = rl.ffi.new('struct Camera3D *', [ diff --git a/examples/shaders/shaders_write_depth.py b/examples/shaders/shaders_write_depth.py index 5e4f27a..4c51249 100644 --- a/examples/shaders/shaders_write_depth.py +++ b/examples/shaders/shaders_write_depth.py @@ -9,7 +9,7 @@ def LoadRenderTextureDepthTex(width, height): target = RenderTexture() - target.id = rl_load_framebuffer(width, height) # Load an empty framebuffer + target.id = rl_load_framebuffer() # Load an empty framebuffer if target.id > 0: @@ -72,12 +72,7 @@ shader = load_shader("","resources/shaders/glsl330/write_depth.fs") target = LoadRenderTextureDepthTex(screenWidth, screenHeight) # Define the camera to look into our 3d world -camera = Camera3D() -camera.position = (2.0, 2.0, 3.0) # Camera position -camera.target = (0.0, 0.5, 0.0) # Camera looking at point -camera.up = (0.0, 1.0, 0.0) # Camera up vector (rotation towards target) -camera.fovy = 45.0 # Camera field-of-view Y -camera.projection = CameraProjection.CAMERA_PERSPECTIVE # Camera projection type +camera = Camera3D((2.0, 2.0, 3.0),(0.0, 0.5, 0.0),(0.0, 1.0, 0.0),45.0, CameraProjection.CAMERA_PERSPECTIVE) set_target_fps(60) # Set our game to run at 60 frames-per-second diff --git a/examples/shapes/shapes_basic_shapes.py b/examples/shapes/shapes_basic_shapes.py index 864346b..5f039a3 100644 --- a/examples/shapes/shapes_basic_shapes.py +++ b/examples/shapes/shapes_basic_shapes.py @@ -1,19 +1,4 @@ import pyray -from raylib.colors import ( - RAYWHITE, - DARKGRAY, - DARKBLUE, - SKYBLUE, - MAROON, - ORANGE, - RED, - VIOLET, - BEIGE, - BROWN, - BLACK, - GREEN, - GOLD -) # Initialization @@ -33,37 +18,37 @@ while not pyray.window_should_close(): # Draw pyray.begin_drawing() - pyray.clear_background(RAYWHITE) + pyray.clear_background(pyray.RAYWHITE) - pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, DARKGRAY) + pyray.draw_text("some basic shapes available on raylib", 20, 20, 20, pyray.DARKGRAY) # Circle shapes and lines - pyray.draw_circle(screenWidth // 5, 120, 35, DARKBLUE) - pyray.draw_circle_gradient(screenWidth // 5, 220, 60, GREEN, SKYBLUE) - pyray.draw_circle_lines(screenWidth // 5, 340, 80, DARKBLUE) + pyray.draw_circle(screenWidth // 5, 120, 35, pyray.DARKBLUE) + pyray.draw_circle_gradient(screenWidth // 5, 220, 60, pyray.GREEN, pyray.SKYBLUE) + pyray.draw_circle_lines(screenWidth // 5, 340, 80, pyray.DARKBLUE) # Rectangle shapes and lines - pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, RED) - pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, MAROON, GOLD) - pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, ORANGE) + pyray.draw_rectangle(screenWidth // 4 * 2 - 60, 100, 120, 60, pyray.RED) + pyray.draw_rectangle_gradient_h(screenWidth // 4 * 2 - 90, 170, 180, 130, pyray.MAROON, pyray.GOLD) + pyray.draw_rectangle_lines(screenWidth // 4 * 2 - 40, 320, 80, 60, pyray.ORANGE) # Triangle shapes and lines pyray.draw_triangle(pyray.Vector2(screenWidth / 4.0 * 3.0, 80.0), pyray.Vector2(screenWidth / 4.0 * 3.0 - 60.0, 150.0), - pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), VIOLET) + pyray.Vector2(screenWidth / 4.0 * 3.0 + 60.0, 150.0), pyray.VIOLET) pyray.draw_triangle_lines(pyray.Vector2(screenWidth / 4.0 * 3.0, 160.0), pyray.Vector2(screenWidth / 4.0 * 3.0 - 20.0, 230.0), - pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), DARKBLUE) + pyray.Vector2(screenWidth / 4.0 * 3.0 + 20.0, 230.0), pyray.DARKBLUE) # Polygon shapes and lines - pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, BROWN) - pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, BROWN) - pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, BEIGE) + pyray.draw_poly(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 80, rotation, pyray.BROWN) + pyray.draw_poly_lines(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 90, rotation, pyray.BROWN) + pyray.draw_poly_lines_ex(pyray.Vector2(screenWidth / 4.0 * 3, 330), 6, 85, rotation, 6, pyray.BEIGE) # NOTE: We draw all LINES based shapes together to optimize internal drawing, # this way, all LINES are rendered in a single draw pass - pyray.draw_line(18, 42, screenWidth - 18, 42, BLACK) + pyray.draw_line(18, 42, screenWidth - 18, 42, pyray.BLACK) pyray.end_drawing() diff --git a/examples/shapes/shapes_bouncing_ball.py b/examples/shapes/shapes_bouncing_ball.py index f0e60f2..cc38371 100644 --- a/examples/shapes/shapes_bouncing_ball.py +++ b/examples/shapes/shapes_bouncing_ball.py @@ -17,7 +17,7 @@ pyray.set_target_fps(60) # Main game loop while not pyray.window_should_close(): # Update - if pyray.is_key_pressed(pyray.KEY_SPACE): + if pyray.is_key_pressed(pyray.KeyboardKey.KEY_SPACE): pause = not pause if not pause: diff --git a/examples/shapes/shapes_draw_rounded_rectangle_incomplete.py b/examples/shapes/shapes_draw_rounded_rectangle_incomplete.py index 078b083..d20d98b 100644 --- a/examples/shapes/shapes_draw_rounded_rectangle_incomplete.py +++ b/examples/shapes/shapes_draw_rounded_rectangle_incomplete.py @@ -12,13 +12,6 @@ #********************************************************************************************/ import pyray -from raylib.colors import ( - RAYWHITE, - LIGHTGRAY, - DARKGRAY, - GOLD, - MAROON, -) SCREEN_WIDTH = 800 @@ -50,17 +43,17 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke #// Draw #//---------------------------------------------------------------------------------- pyray.begin_drawing() - pyray.clear_background(RAYWHITE) + pyray.clear_background(pyray.RAYWHITE) - pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.6)) - pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(LIGHTGRAY,0.3)) + pyray.draw_line(560,0,560,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.6)) + pyray.draw_rectangle(560,0,pyray.get_screen_width()-500,pyray.get_screen_height(),pyray.fade(pyray.LIGHTGRAY,0.3)) if drawRect: - pyray.draw_rectangle_rec(rec,pyray.fade(GOLD,0.6)) + pyray.draw_rectangle_rec(rec,pyray.fade(pyray.GOLD,0.6)) if drawRoundedRect: - pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(MAROON,0.2)) + pyray.draw_rectangle_rounded(rec,roundness,segments,pyray.fade(pyray.MAROON,0.2)) if drawRoundedLines: - pyray.draw_rectangle_rounded_lines(rec,roundness,segments,lineThick,pyray.fade(MAROON,0.4)) + pyray.draw_rectangle_rounded_lines(rec,roundness,segments,pyray.fade(pyray.MAROON,0.4)) #// Draw GUI controls #//------------------------------------------------------------------------------ @@ -79,7 +72,7 @@ while not pyray.window_should_close(): #// Detect window close button or ESC ke # drawRect = pyray.gui_check_box(pyray.Rectangle(640,380,20,20),"DrawRect",drawRect) #//------------------------------------------------------------------------------ - pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, MAROON if segments >= 4 else DARKGRAY) + pyray.draw_text( "MANUAL" if segments >= 4 else "AUTO" , 640, 280, 10, pyray.MAROON if segments >= 4 else pyray.DARKGRAY) pyray.draw_fps(10,10) pyray.end_drawing() #//------------------------------------------------------------------------------ diff --git a/examples/shapes/shapes_following_eyes.py b/examples/shapes/shapes_following_eyes.py index 5f99e0e..66568eb 100644 --- a/examples/shapes/shapes_following_eyes.py +++ b/examples/shapes/shapes_following_eyes.py @@ -5,13 +5,7 @@ raylib [shapes] example - Following Eyes """ from pyray import * -from raylib.colors import ( - RAYWHITE, - BROWN, - BLACK, - LIGHTGRAY, - DARKGREEN, -) + from math import ( atan2, cos, diff --git a/examples/shapes/shapes_lines_bezier.py b/examples/shapes/shapes_lines_bezier.py index c3c0952..2b3d0af 100644 --- a/examples/shapes/shapes_lines_bezier.py +++ b/examples/shapes/shapes_lines_bezier.py @@ -5,11 +5,6 @@ raylib [shapes] example - Lines Bezier """ from pyray import * -from raylib.colors import ( - RAYWHITE, - GRAY, - RED -) # ------------------------------------------------------------------------------------ diff --git a/examples/shapes/shapes_logo_raylib.py b/examples/shapes/shapes_logo_raylib.py index d91bc0b..77579fc 100644 --- a/examples/shapes/shapes_logo_raylib.py +++ b/examples/shapes/shapes_logo_raylib.py @@ -4,11 +4,7 @@ raylib [shapes] example - Logo Raylib """ from pyray import * -from raylib.colors import ( - RAYWHITE, - BLACK, - GRAY -) + # Initialization screenWidth = 800 diff --git a/examples/textures/textures_bunnymark.py b/examples/textures/textures_bunnymark.py index d30c460..0b8c7c2 100644 --- a/examples/textures/textures_bunnymark.py +++ b/examples/textures/textures_bunnymark.py @@ -38,9 +38,9 @@ bunnies = [] for i in range(0, MAX_BUNNIES): bunnies.append(Bunny()) -bunniesCount = 0; # Bunnies counter +bunniesCount = 0 # Bunnies counter -SetTargetFPS(60); # Set our game to run at 60 frames-per-second +SetTargetFPS(60) # Set our game to run at 60 frames-per-second #//-------------------------------------------------------------------------------------- #// Main game loop @@ -63,8 +63,8 @@ while not WindowShouldClose(): #// Detect window close button or ESC key # // Update bunnies for i in range(0, bunniesCount): - bunnies[i].position.x += bunnies[i].speed.x; - bunnies[i].position.y += bunnies[i].speed.y; + bunnies[i].position.x += bunnies[i].speed.x + bunnies[i].position.y += bunnies[i].speed.y if ((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0): bunnies[i].speed.x *= -1 @@ -104,7 +104,7 @@ while not WindowShouldClose(): #// Detect window close button or ESC key #//-------------------------------------------------------------------------------------- -UnloadTexture(texBunny); #Unload bunny texture +UnloadTexture(texBunny) #Unload bunny texture CloseWindow() # Close window and OpenGL context #//-------------------------------------------------------------------------------------- diff --git a/examples/textures/textures_bunnymark_more_pythonic.py b/examples/textures/textures_bunnymark_more_pythonic.py index 19768af..9792da8 100644 --- a/examples/textures/textures_bunnymark_more_pythonic.py +++ b/examples/textures/textures_bunnymark_more_pythonic.py @@ -36,9 +36,9 @@ bunnies = [] for i in range(0, MAX_BUNNIES): bunnies.append(Bunny()) -bunniesCount = 0; # Bunnies counter +bunniesCount = 0 # Bunnies counter -SetTargetFPS(60); # Set our game to run at 60 frames-per-second +SetTargetFPS(60) # Set our game to run at 60 frames-per-second #//-------------------------------------------------------------------------------------- #// Main game loop diff --git a/examples/textures/textures_mouse_painting.py b/examples/textures/textures_mouse_painting.py index 9cf45c0..787b332 100644 --- a/examples/textures/textures_mouse_painting.py +++ b/examples/textures/textures_mouse_painting.py @@ -4,16 +4,6 @@ raylib [texture] example - Mouse Painting """ from pyray import * -from raylib.colors import * -from raylib import ( - KEY_RIGHT, - KEY_LEFT, - MOUSE_BUTTON_LEFT, - KEY_C, - GESTURE_DRAG, - MOUSE_BUTTON_RIGHT, - KEY_S -) MAX_COLORS_COUNT = 23 # Number of colors available @@ -62,9 +52,9 @@ while not window_should_close(): # Detect window close button or ESC key mousePos = get_mouse_position() # Move between colors with keys - if is_key_pressed(KEY_RIGHT): + if is_key_pressed(KeyboardKey.KEY_RIGHT): colorSelected += 1 - elif is_key_pressed(KEY_LEFT): + elif is_key_pressed(KeyboardKey.KEY_LEFT): colorSelected -= 1 if colorSelected >= MAX_COLORS_COUNT: @@ -80,7 +70,7 @@ while not window_should_close(): # Detect window close button or ESC key else: colorMouseHover = -1 - if colorMouseHover >= 0 and is_mouse_button_pressed(MOUSE_BUTTON_LEFT): + if colorMouseHover >= 0 and is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT): colorSelected = colorMouseHover colorSelectedPrev = colorSelected @@ -89,13 +79,13 @@ while not window_should_close(): # Detect window close button or ESC key if brushSize < 2: brushSize = 2 if brushSize > 50: brushSize = 50 - if is_key_pressed(KEY_C): + if is_key_pressed(KeyboardKey.KEY_C): # Clear render texture to clear color begin_texture_mode(target) clear_background(colors[0]) end_texture_mode() - if is_mouse_button_pressed(MOUSE_BUTTON_LEFT) or get_gesture_detected() == GESTURE_DRAG: + if is_mouse_button_pressed(MouseButton.MOUSE_BUTTON_LEFT) or get_gesture_detected() == Gesture.GESTURE_DRAG: # Paint circle into render texture # NOTE: To avoid discontinuous circles, we could store @@ -104,7 +94,7 @@ while not window_should_close(): # Detect window close button or ESC key if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[colorSelected]) end_texture_mode() - if is_mouse_button_down(MOUSE_BUTTON_RIGHT): + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT): if not mouseWasPressed: colorSelectedPrev = colorSelected @@ -117,7 +107,7 @@ while not window_should_close(): # Detect window close button or ESC key if mousePos.y > 50: draw_circle(int(mousePos.x), int(mousePos.y), brushSize, colors[0]) end_texture_mode() - elif is_mouse_button_released(MOUSE_BUTTON_RIGHT) and mouseWasPressed: + elif is_mouse_button_released(MouseButton.MOUSE_BUTTON_RIGHT) and mouseWasPressed: colorSelected = colorSelectedPrev mouseWasPressed = False @@ -130,7 +120,7 @@ while not window_should_close(): # Detect window close button or ESC key # Image saving logic # NOTE: Saving painted texture to a default named image - if (btnSaveMouseHover and is_mouse_button_released(MOUSE_BUTTON_LEFT)) or is_key_pressed(KEY_S): + if (btnSaveMouseHover and is_mouse_button_released(MouseButton.MOUSE_BUTTON_LEFT)) or is_key_pressed(KeyboardKey.KEY_S): image = load_image_from_texture(target.texture) image_flip_vertical(image) export_image(image, "my_amazing_texture_painting.png") @@ -157,7 +147,7 @@ while not window_should_close(): # Detect window close button or ESC key # Draw drawing circle for reference if mousePos.y > 50: - if is_mouse_button_down(MOUSE_BUTTON_RIGHT): + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT): draw_circle_lines(int(mousePos.x), int(mousePos.y), brushSize, GRAY) else: draw_circle(get_mouse_x(), get_mouse_y(), brushSize, colors[colorSelected]) diff --git a/examples/textures/textures_to_image.py b/examples/textures/textures_to_image.py index 9b713a7..87ec5ab 100644 --- a/examples/textures/textures_to_image.py +++ b/examples/textures/textures_to_image.py @@ -39,6 +39,8 @@ while not window_should_close(): # Detect window close button or ESC key clear_background(RAYWHITE) + texture.width + draw_texture(texture, int(screenWidth/2 - texture.width/2), int(screenHeight/2 - texture.height/2), WHITE) draw_text("this IS a texture loaded from an image!", 300, 370, 10, GRAY)