diff --git a/examples/core/core_2d_camera.py b/examples/core/core_2d_camera.py index 57c6dd6..e95ea64 100644 --- a/examples/core/core_2d_camera.py +++ b/examples/core/core_2d_camera.py @@ -5,7 +5,7 @@ raylib [core] example - 2D Camera System """ import pyray -from raylib.colors import ( +from pyray import ( RAYWHITE, DARKGRAY, RED, @@ -15,16 +15,12 @@ from raylib.colors import ( BLACK, ) - - - # Initialization MAX_BUILDINGS = 100 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - 2d camera') +pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,'raylib [core] example - 2d camera') player = pyray.Rectangle(400, 280, 40, 40) buildings = [] @@ -56,7 +52,6 @@ camera.zoom = 1.0 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 @@ -133,6 +128,5 @@ while not pyray.window_should_close(): # Detect window close button or ESC key pyray.end_drawing() - # De-Initialization pyray.close_window() # Close window and OpenGL context diff --git a/examples/core/core_2d_camera_platformer.py b/examples/core/core_2d_camera_platformer.py index 875c9f6..35f4de9 100644 --- a/examples/core/core_2d_camera_platformer.py +++ b/examples/core/core_2d_camera_platformer.py @@ -6,7 +6,7 @@ raylib [core] example - 2D Camera platformer from math import sqrt import pyray -from raylib.colors import ( +from pyray import ( DARKGRAY, RED, BLACK, @@ -14,8 +14,6 @@ from raylib.colors import ( LIGHTGRAY, ) - - # Initialization global g_evening_out, g_even_out_target g_evening_out = False @@ -27,8 +25,7 @@ PLAYER_HOR_SPD = 200.0 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - 2d camera') +pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - 2d camera') # Raylib Math @@ -77,11 +74,11 @@ def update_player(player, env_items, delta): for ei in env_items: p = player.position if ( - ei.blocking and - ei.rect.x <= p.x and - ei.rect.x + ei.rect.width >= p.x and - ei.rect.y >= p.y and - ei.rect.y < p.y + player.speed * delta + ei.blocking and + ei.rect.x <= p.x and + ei.rect.x + ei.rect.width >= p.x and + ei.rect.y >= p.y and + ei.rect.y < p.y + player.speed * delta ): hit_obstacle = True player.speed = 0.0 @@ -96,14 +93,14 @@ def update_player(player, env_items, delta): def update_camera_center( - camera, player, env_items, delta, width, height + camera, player, env_items, delta, width, height ): camera.offset = pyray.Vector2(width / 2, height / 2) camera.target = player.position def update_camera_center_inside_map( - camera, player, env_items, delta, width, height + camera, player, env_items, delta, width, height ): camera.target = player.position camera.offset = pyray.Vector2(width / 2, height / 2) @@ -134,7 +131,7 @@ def update_camera_center_inside_map( def update_camera_center_smooth_follow( - camera, player, env_items, delta, width, height + camera, player, env_items, delta, width, height ): min_speed = 30 min_effect_length = 10 @@ -152,7 +149,7 @@ def update_camera_center_smooth_follow( def update_camera_even_out_on_landing( - camera, player, env_items, delta, width, height + camera, player, env_items, delta, width, height ): global g_evening_out, g_even_out_target @@ -175,16 +172,16 @@ def update_camera_even_out_on_landing( g_evening_out = False else: if ( - player.can_jump and - (player.speed == 0) and - (player.position.y != camera.target.y) + player.can_jump and + (player.speed == 0) and + (player.position.y != camera.target.y) ): g_evening_out = True g_even_out_target = player.position.y def update_camera_player_bounds_push( - camera, player, env_items, delta, width, height + camera, player, env_items, delta, width, height ): bbox = pyray.Vector2(0.2, 0.2) @@ -207,11 +204,11 @@ def update_camera_player_bounds_push( camera.target.y = player.position.y if player.position.x > bbox_world_max.x: camera.target.x = ( - bbox_world_min.x + (player.position.x - bbox_world_max.x) + bbox_world_min.x + (player.position.x - bbox_world_max.x) ) if player.position.y > bbox_world_max.y: camera.target.y = ( - bbox_world_min.y + (player.position.y - bbox_world_max.y) + bbox_world_min.y + (player.position.y - bbox_world_max.y) ) diff --git a/examples/core/core_3d_camera_free.py b/examples/core/core_3d_camera_free.py index fa04dd3..2ae7db0 100644 --- a/examples/core/core_3d_camera_free.py +++ b/examples/core/core_3d_camera_free.py @@ -1,5 +1,3 @@ -from raylib import Fade -import pyray from pyray import * # Initialization @@ -14,7 +12,7 @@ camera.position = Vector3(10.0, 10.0, 10.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 = 45.0 # Camera field-of-view Y -camera.projection = pyray.CAMERA_PERSPECTIVE # Camera projection type +camera.projection = CameraProjection.CAMERA_PERSPECTIVE # Camera projection type cubePosition = Vector3(0.0, 0.0, 0.0) @@ -25,9 +23,9 @@ set_target_fps(60) # Set our game to run at 60 frames-per-second # Main game loop while not window_should_close(): # Detect window close button or ESC key # Update - update_camera(camera, pyray.CAMERA_FREE) + update_camera(camera, CameraMode.CAMERA_FREE) - if is_key_pressed(pyray.KEY_Z): + if is_key_pressed(KEY_Z): camera.target = Vector3(0.0, 0.0, 0.0) # Draw @@ -44,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key end_mode_3d() - draw_rectangle(10, 10, 320, 93, Fade(SKYBLUE, 0.5)) + draw_rectangle(10, 10, 320, 93, fade(SKYBLUE, 0.5)) draw_rectangle_lines(10, 10, 320, 93, BLUE) draw_text("Free camera default controls:", 20, 20, 10, BLACK) diff --git a/examples/core/core_3d_camera_mode.py b/examples/core/core_3d_camera_mode.py index a03cd55..79b7b63 100644 --- a/examples/core/core_3d_camera_mode.py +++ b/examples/core/core_3d_camera_mode.py @@ -17,7 +17,7 @@ camera.position = pyray.Vector3(0.0, 10.0, 10.0) # Camera position camera.target = pyray.Vector3(0.0, 0.0, 0.0) # Camera looking at point camera.up = pyray.Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target) camera.fovy = 45.0 # Camera field-of-view Y -camera.projection = pyray.CAMERA_PERSPECTIVE # Camera mode type +camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera mode type cube_position = pyray.Vector3(0.0, 0.0, 0.0) diff --git a/examples/core/core_basic_screen_manager.py b/examples/core/core_basic_screen_manager.py index e6abb79..fbe473e 100644 --- a/examples/core/core_basic_screen_manager.py +++ b/examples/core/core_basic_screen_manager.py @@ -13,8 +13,7 @@ class GameScreen(Enum): def main(): - init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - "raylib [core] example - basic screen manager") + init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - basic screen manager") frame_count = 0 set_target_fps(60) diff --git a/examples/core/core_basic_window.py b/examples/core/core_basic_window.py index 3bbe02b..b5b0e22 100644 --- a/examples/core/core_basic_window.py +++ b/examples/core/core_basic_window.py @@ -4,21 +4,12 @@ raylib [core] example - Basic window """ import pyray -from raylib.colors import ( - RAYWHITE, - LIGHTGRAY, -) - - - - # Initialization SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - basic window') +pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - basic window') pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second @@ -30,9 +21,9 @@ 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_text( - 'Congrats! You created your first window!', 190, 200, 20, LIGHTGRAY) + 'Congrats! You created your first window!', 190, 200, 20, pyray.LIGHTGRAY) pyray.end_drawing() diff --git a/examples/core/core_drop_files.py b/examples/core/core_drop_files.py index dc0efa3..d55e4d3 100644 --- a/examples/core/core_drop_files.py +++ b/examples/core/core_drop_files.py @@ -21,44 +21,37 @@ from raylib.colors import ( screenWidth = 800 screenHeight = 450 -pyray.init_window(screenWidth, screenHeight, - 'raylib [core] example - drop files') +pyray.init_window(screenWidth, screenHeight, 'raylib [core] example - drop files') pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second +droppedFiles = pyray.FilePathList() + -count_pointer = pyray.ffi.new("int *", 0) -count = 0 while not pyray.window_should_close(): if pyray.is_file_dropped(): - droppedFiles_pointer = pyray.get_dropped_files(count_pointer) - count = count_pointer[0] - # This isn't actually necessary unless you want a Python array: - droppedFiles = pyray.ffi.unpack(droppedFiles_pointer, count) + droppedFiles = pyray.load_dropped_files() + pyray.begin_drawing() pyray.clear_background(RAYWHITE) - if count == 0: + if droppedFiles.count == 0: pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY) else: - pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY); + pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY) - for i in range(0, count): + 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)) else: pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3)) - filename = pyray.ffi.string(droppedFiles[i]).decode('utf-8') - # This alternative works too if you don't have a Python array: - # filename = pyray.ffi.string(droppedFiles_pointer[i]).decode('utf-8') - pyray.draw_text(filename, 120, 100 + 40*i, 10, GRAY) + pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY) - pyray.draw_text("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY); + pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY) pyray.end_drawing() # De-Initialization -pyray.clear_dropped_files() pyray.close_window() # Close window and OpenGL context diff --git a/examples/core/core_drop_files2.py b/examples/core/core_drop_files2.py deleted file mode 100644 index 22cea3c..0000000 --- a/examples/core/core_drop_files2.py +++ /dev/null @@ -1,65 +0,0 @@ -""" - -* raylib [core] example - Windows drop files -* -* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) - -""" -import pyray -from raylib.colors import ( - RAYWHITE, - DARKGRAY, - LIGHTGRAY, - GRAY -) - -screenWidth = 800 -screenHeight = 450 - -pyray.init_window(screenWidth, screenHeight, - 'raylib [core] example - drop files') -pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second - -droppedFiles = [] - -def get_dropped_files(): - count_pointer = pyray.ffi.new("int *", 0) - droppedFiles_pointer = pyray.get_dropped_files(count_pointer) - d = [] - for i in range(0, count_pointer[0]): - d.append(pyray.ffi.string(droppedFiles_pointer[i]).decode('utf-8')) - return d - - -while not pyray.window_should_close(): - - if pyray.is_file_dropped(): - droppedFiles = get_dropped_files() - - pyray.begin_drawing() - - pyray.clear_background(RAYWHITE) - - if len(droppedFiles) == 0: - pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY) - else: - pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY); - - for i in range(0, len(droppedFiles)): - if i % 2 == 0: - pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5)) - else: - pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3)) - pyray.draw_text(droppedFiles[i], 120, 100 + 40*i, 10, GRAY) - - pyray.draw_text("Drop new files...", 100, 110 + 40*len(droppedFiles), 20, DARKGRAY); - pyray.end_drawing() - -# De-Initialization -pyray.clear_dropped_files() -pyray.close_window() # Close window and OpenGL context diff --git a/examples/core/core_input_gestures.py b/examples/core/core_input_gestures.py index 44b7e79..86024ab 100644 --- a/examples/core/core_input_gestures.py +++ b/examples/core/core_input_gestures.py @@ -19,8 +19,7 @@ MAX_GESTURE_STRINGS = 20 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - input gestures') +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) diff --git a/examples/core/core_input_keys.py b/examples/core/core_input_keys.py index bfd9465..4c57544 100644 --- a/examples/core/core_input_keys.py +++ b/examples/core/core_input_keys.py @@ -4,21 +4,13 @@ raylib [core] example - Keyboard input """ import pyray -from raylib.colors import ( - RAYWHITE, - DARKGRAY, - MAROON, -) - - # Initialization SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - keyboard input') +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 @@ -39,9 +31,9 @@ while not pyray.window_should_close(): # Detect window close button or ESC key # Draw pyray.begin_drawing() - pyray.clear_background(RAYWHITE) - pyray.draw_text('move the ball with arrow keys', 10, 10, 20, DARKGRAY) - pyray.draw_circle_v(ball_position, 50, MAROON) + pyray.clear_background(pyray.RAYWHITE) + pyray.draw_text('move the ball with arrow keys', 10, 10, 20, pyray.DARKGRAY) + pyray.draw_circle_v(ball_position, 50, pyray.MAROON) pyray.end_drawing() diff --git a/examples/core/core_input_mouse.py b/examples/core/core_input_mouse.py index a946965..bea22e5 100644 --- a/examples/core/core_input_mouse.py +++ b/examples/core/core_input_mouse.py @@ -4,33 +4,13 @@ raylib [core] example - Mouse input """ from pyray import * -from raylib.colors import ( - RAYWHITE, - DARKGRAY, - MAROON, - LIME, - DARKBLUE, - PURPLE, - YELLOW, - ORANGE, - BEIGE, -) -from raylib import ( - MOUSE_BUTTON_LEFT, - MOUSE_BUTTON_MIDDLE, - MOUSE_BUTTON_RIGHT, - MOUSE_BUTTON_SIDE, - MOUSE_BUTTON_EXTRA, - MOUSE_BUTTON_FORWARD, - MOUSE_BUTTON_BACK -) + # Initialization SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - mouse input') +init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - mouse input') ball_position = Vector2(-100, -100) ball_color = DARKBLUE diff --git a/examples/core/core_input_mouse_wheel.py b/examples/core/core_input_mouse_wheel.py index da020c7..836cf22 100644 --- a/examples/core/core_input_mouse_wheel.py +++ b/examples/core/core_input_mouse_wheel.py @@ -4,13 +4,6 @@ raylib [core] example - Mouse wheel input """ import pyray -from raylib.colors import ( - RAYWHITE, - GRAY, - LIGHTGRAY, - MAROON, -) - @@ -19,8 +12,7 @@ from raylib.colors import ( SCREEN_WIDTH = 800 SCREEN_HEIGHT = 450 -pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, - 'raylib [core] example - input mouse wheel') +pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - input mouse wheel') box_position_y: int = SCREEN_HEIGHT // 2 - 40 scroll_speed = 4 # Scrolling speed in pixels @@ -36,14 +28,14 @@ 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(SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, MAROON) + pyray.draw_rectangle(SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, pyray.MAROON) pyray.draw_text('User mouse wheel to move the cube up and down!', - 10, 10, 20, GRAY) + 10, 10, 20, pyray.GRAY) pyray.draw_text('Box position Y: {:03d}'.format(box_position_y), - 10, 40, 20, LIGHTGRAY) + 10, 40, 20, pyray.LIGHTGRAY) pyray.end_drawing() diff --git a/examples/core/core_random_values.py b/examples/core/core_random_values.py index 0983c5b..7f63ec3 100644 --- a/examples/core/core_random_values.py +++ b/examples/core/core_random_values.py @@ -4,11 +4,6 @@ raylib [core] example - random values """ from pyray import * -from raylib.colors import ( - RAYWHITE, - MAROON, - LIGHTGRAY -) # Initialization SCREEN_WIDTH = 800 diff --git a/examples/core/core_scissor_test.py b/examples/core/core_scissor_test.py index e205773..c2e43ad 100644 --- a/examples/core/core_scissor_test.py +++ b/examples/core/core_scissor_test.py @@ -4,15 +4,7 @@ raylib [core] example - Scissor Test """ from pyray import * -from raylib.colors import ( - RAYWHITE, - LIGHTGRAY, - RED, - BLACK -) -from raylib import ( - KEY_S -) + # Initialization # -------------------------------------------------------------------------------------- diff --git a/examples/core/core_smooth pixel-perfect camera.py b/examples/core/core_smooth_pixel_perfect_camera.py similarity index 97% rename from examples/core/core_smooth pixel-perfect camera.py rename to examples/core/core_smooth_pixel_perfect_camera.py index aec4e91..15b600c 100644 --- a/examples/core/core_smooth pixel-perfect camera.py +++ b/examples/core/core_smooth_pixel_perfect_camera.py @@ -87,4 +87,4 @@ while not window_should_close(): # Detect window close button or ESC key unload_render_texture(target) # Unload render texture -close_window(); # Close window and OpenGL context \ No newline at end of file +close_window() # Close window and OpenGL context \ No newline at end of file diff --git a/examples/core/core_split_screen.py b/examples/core/core_split_screen.py index 91d440e..a6961f2 100644 --- a/examples/core/core_split_screen.py +++ b/examples/core/core_split_screen.py @@ -6,13 +6,6 @@ raylib [core] example - Split Screen from pyray import * -from raylib import ( - KEY_W, - KEY_S, - KEY_UP, - KEY_DOWN, -) - cameraPlayer1 = Camera3D([0]) cameraPlayer2 = Camera3D([0]) diff --git a/examples/core/core_window_should_close.py b/examples/core/core_window_should_close.py index 4a0e391..aecebe4 100644 --- a/examples/core/core_window_should_close.py +++ b/examples/core/core_window_should_close.py @@ -4,18 +4,6 @@ raylib [core] example - Window Should Close """ from pyray import * -from raylib.colors import ( - RAYWHITE, - LIGHTGRAY, - WHITE, - BLACK -) -from raylib import ( - KEY_NULL, - KEY_ESCAPE, - KEY_Y, - KEY_N -) # Initialization # --------------------------------------------------------------------------------------