update DLLs

This commit is contained in:
richard 2021-06-22 13:40:34 +01:00
parent f6f5b0836e
commit d1dc703292
7 changed files with 61 additions and 25 deletions

View file

@ -9,7 +9,9 @@
# *
# ********************************************************************************************/
from raylib.static import *
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
@ -29,10 +31,10 @@ class Bunny:
screenWidth = 1920;
screenHeight = 1080;
InitWindow(screenWidth, screenHeight, b"raylib [textures] example - bunnymark")
rl.InitWindow(screenWidth, screenHeight, b"raylib [textures] example - bunnymark")
# // Load bunny texture
texBunny = LoadTexture(b"resources/wabbit_alpha.png")
texBunny = rl.LoadTexture(b"resources/wabbit_alpha.png")
bunnies = []
for i in range(0, MAX_BUNNIES):
@ -40,23 +42,23 @@ for i in range(0, MAX_BUNNIES):
bunniesCount = 0; # Bunnies counter
SetTargetFPS(60); # Set our game to run at 60 frames-per-second
rl.SetTargetFPS(60); # Set our game to run at 60 frames-per-second
#//--------------------------------------------------------------------------------------
#// Main game loop
while not WindowShouldClose(): #// Detect window close button or ESC key
while not rl.WindowShouldClose(): #// Detect window close button or ESC key
#// Update
#//----------------------------------------------------------------------------------
if IsMouseButtonDown(MOUSE_LEFT_BUTTON):
if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON):
#// Create more bunnies
for i in range(0, 100):
if bunniesCount < MAX_BUNNIES:
bunnies[bunniesCount].position = GetMousePosition()
bunnies[bunniesCount].speed.x = GetRandomValue(-250, 250)/60.0
bunnies[bunniesCount].speed.y = GetRandomValue(-250, 250)/60.0
bunnies[bunniesCount].color = (GetRandomValue(50, 240),
GetRandomValue(80, 240),
GetRandomValue(100, 240), 255 )
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
@ -66,18 +68,18 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
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):
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) > GetScreenHeight()) or ((bunnies[i].position.y + texBunny.height/2 - 40) < 0):
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
# //----------------------------------------------------------------------------------
BeginDrawing()
rl.BeginDrawing()
ClearBackground(RAYWHITE)
rl.ClearBackground(RAYWHITE)
for i in range(0, bunniesCount):
# // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS),
@ -86,17 +88,17 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
# // 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
DrawTexture(texBunny, int(bunnies[i].position.x), int(bunnies[i].position.y), bunnies[i].color)
rl.DrawTexture(texBunny, int(bunnies[i].position.x), int(bunnies[i].position.y), bunnies[i].color)
DrawRectangle(0, 0, screenWidth, 40, BLACK)
rl.DrawRectangle(0, 0, screenWidth, 40, BLACK)
text = f"bunnies {bunniesCount}"
DrawText(text.encode('utf-8'), 120, 10, 20, GREEN)
rl.DrawText(text.encode('utf-8'), 120, 10, 20, GREEN)
text = f"batched draw calls: { 1 + int(bunniesCount/MAX_BATCH_ELEMENTS)}"
DrawText(text.encode('utf-8'), 320, 10, 20, MAROON)
rl.DrawText(text.encode('utf-8'), 320, 10, 20, MAROON)
DrawFPS(10, 10)
rl.DrawFPS(10, 10)
EndDrawing()
rl.EndDrawing()
#//----------------------------------------------------------------------------------
@ -104,8 +106,8 @@ while not WindowShouldClose(): #// Detect window close button or ESC key
#//--------------------------------------------------------------------------------------
UnloadTexture(texBunny); #Unload bunny texture
rl.UnloadTexture(texBunny); #Unload bunny texture
CloseWindow() # Close window and OpenGL context
rl.CloseWindow() # Close window and OpenGL context
#//--------------------------------------------------------------------------------------