diff --git a/examples/core/core_2d_camera.py b/examples/core/core_2d_camera.py index ece199e..e70b516 100644 --- a/examples/core/core_2d_camera.py +++ b/examples/core/core_2d_camera.py @@ -3,7 +3,8 @@ raylib [core] example - 2d camera """ -from raylib.pyray import PyRay +import pyray + from raylib.colors import ( RAYWHITE, DARKGRAY, @@ -15,7 +16,7 @@ from raylib.colors import ( ) -pyray = PyRay() + # Initialization MAX_BUILDINGS = 100 diff --git a/examples/core/core_2d_camera_platformer.py b/examples/core/core_2d_camera_platformer.py index 4737798..a4e7648 100644 --- a/examples/core/core_2d_camera_platformer.py +++ b/examples/core/core_2d_camera_platformer.py @@ -5,7 +5,7 @@ raylib [core] example - 2d camera platformer """ from math import sqrt -from raylib.pyray import PyRay +import pyray from raylib.colors import ( DARKGRAY, RED, @@ -15,7 +15,6 @@ from raylib.colors import ( ) -pyray = PyRay() # Initialization global g_evening_out, g_even_out_target diff --git a/examples/core/core_basic_window.py b/examples/core/core_basic_window.py index 7a8cb0f..3bbe02b 100644 --- a/examples/core/core_basic_window.py +++ b/examples/core/core_basic_window.py @@ -3,14 +3,14 @@ raylib [core] example - Basic window """ -from raylib.pyray import PyRay +import pyray from raylib.colors import ( RAYWHITE, LIGHTGRAY, ) -pyray = PyRay() + # Initialization diff --git a/examples/core/core_input_gestures.py b/examples/core/core_input_gestures.py index 9d60bfd..44b7e79 100644 --- a/examples/core/core_input_gestures.py +++ b/examples/core/core_input_gestures.py @@ -3,7 +3,7 @@ raylib [core] example - Input Gestures Detection """ -from raylib.pyray import PyRay +import pyray from raylib.colors import ( RAYWHITE, LIGHTGRAY, @@ -13,7 +13,6 @@ from raylib.colors import ( ) -pyray = PyRay() # Initialization MAX_GESTURE_STRINGS = 20 diff --git a/examples/core/core_input_keys.py b/examples/core/core_input_keys.py index 87883e0..bfd9465 100644 --- a/examples/core/core_input_keys.py +++ b/examples/core/core_input_keys.py @@ -3,7 +3,7 @@ raylib [core] example - Keyboard input """ -from raylib.pyray import PyRay +import pyray from raylib.colors import ( RAYWHITE, DARKGRAY, @@ -11,7 +11,6 @@ from raylib.colors import ( ) -pyray = PyRay() # Initialization diff --git a/examples/core/core_input_mouse.py b/examples/core/core_input_mouse.py index bd6c82d..73ce697 100644 --- a/examples/core/core_input_mouse.py +++ b/examples/core/core_input_mouse.py @@ -3,7 +3,7 @@ raylib [core] example - Mouse input """ -from raylib.pyray import PyRay +import pyray from raylib.colors import ( RAYWHITE, DARKGRAY, @@ -13,7 +13,6 @@ from raylib.colors import ( ) -pyray = PyRay() # Initialization @@ -34,11 +33,11 @@ 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): + if pyray.is_mouse_button_pressed(pyray.MOUSE_BUTTON_LEFT): ball_color = MAROON - elif pyray.is_mouse_button_pressed(pyray.MOUSE_MIDDLE_BUTTON): + elif pyray.is_mouse_button_pressed(pyray.MOUSE_BUTTON_MIDDLE): ball_color = LIME - elif pyray.is_mouse_button_pressed(pyray.MOUSE_RIGHT_BUTTON): + elif pyray.is_mouse_button_pressed(pyray.MOUSE_BUTTON_RIGHT): ball_color = DARKBLUE # Draw diff --git a/examples/core/core_input_mouse_wheel.py b/examples/core/core_input_mouse_wheel.py index 3aee861..8a4951e 100644 --- a/examples/core/core_input_mouse_wheel.py +++ b/examples/core/core_input_mouse_wheel.py @@ -3,7 +3,7 @@ raylib [core] example - Mouse wheel input """ -from raylib.pyray import PyRay +import pyray from raylib.colors import ( RAYWHITE, GRAY, @@ -12,7 +12,7 @@ from raylib.colors import ( ) -pyray = PyRay() + # Initialization @@ -38,6 +38,8 @@ while not pyray.window_should_close(): # Detect window close button or ESC key pyray.clear_background(RAYWHITE) + # TODO + # FIXME pyray.draw_rectangle( SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, MAROON) diff --git a/examples/extra/camera.py b/examples/extra/camera.py index 16b2842..be4fb2b 100644 --- a/examples/extra/camera.py +++ b/examples/extra/camera.py @@ -1,6 +1,6 @@ from math import sin, cos import glm -from raylib.dynamic import raylib as rl, ffi +from raylib import rl, ffi class CameraFly: diff --git a/examples/extra/flow-field.py b/examples/extra/flow-field.py index eff1588..c22a29f 100644 --- a/examples/extra/flow-field.py +++ b/examples/extra/flow-field.py @@ -9,7 +9,7 @@ python3 flow-field import sys, math, time, random import glm -from raylib.dynamic import raylib as rl, ffi +from raylib import rl, ffi from raylib.colors import * CTM = lambda: round(time.time() * 1000) diff --git a/examples/textures/textures_bunnymark.py b/examples/textures/textures_bunnymark.py index 7898a47..d30c460 100644 --- a/examples/textures/textures_bunnymark.py +++ b/examples/textures/textures_bunnymark.py @@ -47,7 +47,7 @@ SetTargetFPS(60); # Set our game to run at 60 frames-per-second while not WindowShouldClose(): #// Detect window close button or ESC key #// Update #//---------------------------------------------------------------------------------- - if IsMouseButtonDown(MOUSE_LEFT_BUTTON): + if IsMouseButtonDown(MOUSE_BUTTON_LEFT): #// Create more bunnies for i in range(0, 100): if bunniesCount < MAX_BUNNIES: diff --git a/examples/textures/textures_bunnymark_dynamic.py b/examples/textures/textures_bunnymark_dynamic.py deleted file mode 100644 index 9c461f6..0000000 --- a/examples/textures/textures_bunnymark_dynamic.py +++ /dev/null @@ -1,113 +0,0 @@ -# /******************************************************************************************* -# * -# * raylib [textures] example - Bunnymark -# * -# * This example has been created using raylib 1.6 (www.raylib.com) -# * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -# * -# * Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -# * -# ********************************************************************************************/ - -from raylib.dynamic import ffi, raylib as rl -from raylib.colors import * - -MAX_BUNNIES = 500000 - -# This is the maximum amount of elements (quads) per batch -# NOTE: This value is defined in [rlgl] module and can be changed there -MAX_BATCH_ELEMENTS = 8192 - - -class Bunny: - def __init__(self): - self.position = ffi.new('struct Vector2 *', [0.0, 0.0]) - self.speed = ffi.new('struct Vector2 *', [0.0, 0.0]) - self.color = ffi.new('struct Color *', [0, 0, 0, 0]) - - -# // Initialization -# //-------------------------------------------------------------------------------------- -screenWidth = 1920; -screenHeight = 1080; - -rl.InitWindow(screenWidth, screenHeight, b"raylib [textures] example - bunnymark") - -# // Load bunny texture -texBunny = rl.LoadTexture(b"resources/wabbit_alpha.png") - -bunnies = [] -for i in range(0, MAX_BUNNIES): - bunnies.append(Bunny()) - -bunniesCount = 0; # Bunnies counter - -rl.SetTargetFPS(60); # Set our game to run at 60 frames-per-second -#//-------------------------------------------------------------------------------------- - -#// Main game loop -while not rl.WindowShouldClose(): #// Detect window close button or ESC key - #// Update - #//---------------------------------------------------------------------------------- - if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON): - #// Create more bunnies - for i in range(0, 100): - if bunniesCount < MAX_BUNNIES: - bunnies[bunniesCount].position = rl.GetMousePosition() - bunnies[bunniesCount].speed.x = rl.GetRandomValue(-250, 250)/60.0 - bunnies[bunniesCount].speed.y = rl.GetRandomValue(-250, 250)/60.0 - bunnies[bunniesCount].color = (rl.GetRandomValue(50, 240), - rl.GetRandomValue(80, 240), - rl.GetRandomValue(100, 240), 255 ) - - bunniesCount+=1 - - - # // Update bunnies - for i in range(0, bunniesCount): - bunnies[i].position.x += bunnies[i].speed.x; - bunnies[i].position.y += bunnies[i].speed.y; - - if ((bunnies[i].position.x + texBunny.width/2) > rl.GetScreenWidth()) or ((bunnies[i].position.x + texBunny.width/2) < 0): - bunnies[i].speed.x *= -1 - if ((bunnies[i].position.y + texBunny.height/2) > rl.GetScreenHeight()) or ((bunnies[i].position.y + texBunny.height/2 - 40) < 0): - bunnies[i].speed.y *= -1 - - # //---------------------------------------------------------------------------------- - # - # // Draw - # //---------------------------------------------------------------------------------- - rl.BeginDrawing() - - rl.ClearBackground(RAYWHITE) - - for i in range(0, bunniesCount): - # // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), - # // a draw call is launched and buffer starts being filled again; - # // before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU... - # // Process of sending data is costly and it could happen that GPU data has not been completely - # // processed for drawing while new data is tried to be sent (updating current in-use buffers) - # // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - rl.DrawTexture(texBunny, int(bunnies[i].position.x), int(bunnies[i].position.y), bunnies[i].color) - - rl.DrawRectangle(0, 0, screenWidth, 40, BLACK) - text = f"bunnies {bunniesCount}" - rl.DrawText(text.encode('utf-8'), 120, 10, 20, GREEN) - text = f"batched draw calls: { 1 + int(bunniesCount/MAX_BATCH_ELEMENTS)}" - rl.DrawText(text.encode('utf-8'), 320, 10, 20, MAROON) - - rl.DrawFPS(10, 10) - - rl.EndDrawing() - #//---------------------------------------------------------------------------------- - - -#// De-Initialization -#//-------------------------------------------------------------------------------------- - - -rl.UnloadTexture(texBunny); #Unload bunny texture - -rl.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 3a9e11f..19768af 100644 --- a/examples/textures/textures_bunnymark_more_pythonic.py +++ b/examples/textures/textures_bunnymark_more_pythonic.py @@ -45,7 +45,7 @@ SetTargetFPS(60); # Set our game to run at 60 frames-per-second while not WindowShouldClose(): #// Detect window close button or ESC key #// Update #//---------------------------------------------------------------------------------- - if IsMouseButtonDown(MOUSE_LEFT_BUTTON): + if IsMouseButtonDown(MOUSE_BUTTON_LEFT): #// Create more bunnies for i in range(0, 100): if bunniesCount < MAX_BUNNIES: