Package: raylib-py
raylib-pyA python binding for the greatClibraryraylib.Release Information:This release was generated from another project, as mentioned in #45.How to install:From PyPI, in the CLI:$ pip install raylib-pyYou can also download the wheel from thereleasespage and install it with pip locally:$ pip install path/to/raylib_py-4.5.0-py3-none-any.whlHow to use:Try this (after installed raylib-py, create a new python file, save the code below into it, then run it):fromraylibpyimport*defmain():init_window(800,450,"raylib [core] example - basic window")set_target_fps(60)whilenotwindow_should_close():begin_drawing()clear_background(RAYWHITE)draw_text("Congrats! You created your first window!",190,200,20,LIGHTGRAY)end_drawing()close_window()if__name__=='__main__':main()Features:PEP8 naming convention only:Structure attributes are insnake_case, classes and other types inPascalCase.Type hinting (not type annotation):defget_ray_collision_mesh(ray,mesh,transform):# type: (Ray, Mesh, Matrix) -> RayCollisionstructures with functions as methods and properties:sound=Sound.load('my/resorces/sound.wav')# same as load_sound(...)position=Vector(4.0,10.0)# later...sound.play()# same as play_sound(sound)length=position.length# same as vector2length(position); uses raymath.h functionsVector{2,3,4}, Rectangle and Color have attribute swizzling;vec3=Vector3(2.0,5.0,3.0)vec2=vec3.zxy# vec2 is a Vector2, not a sequence typeother_vec3=vec2.xxy# same thing: other_vec3 is a Vector3vec2.xy=vec3.y,other_vec3.z# sequences can be set as valuesc_red=Color(255,0,0)c_yellow=c_red.rrb# Rectangles have aliases for width and height: w and h respectively:rect=Rectangle(10.0,10.0,320.0,240.0)other_rect=rect.whxy# swizzling is only allowed when using four attributes, not 3 nor 2Pretty printing: most structures implement__str__()and__repr__()in a friendly way;Context managers: begin_* and end_* functions can be called as context managers:Without context managers:# this example shows a rendering stepbegin_drawing()begin_texture_mode(minimap_texture)# render the "minimap"draw_line(2,2,5,5,RED)end_texture_mode(minimap_texture)begin_mode2d(main_camera)# 2d drawing logic...draw_texture(minimap_texture,10,10,WHITE)end_mode2d()end_drawing()With context managers:# this example shows a rendering stepwithdrawing():withtexture_mode(minimap_texture):# render the minimapdraw_line(2,2,5,5,RED)withmode2d(main_camera):# 2d drawing logic...draw_texture(minimap_texture,10,10,WHITE)Context managers for some structures: Camera{2,3}D, Shader and others;Folowing the example above:# this example shows a rendering stepwithdrawing():withminimap_texture:# render the minimapdraw_line(2,2,5,5,RED)withmain_camera:# 2d drawing logic...draw_texture(minimap_texture,10,10,WHITE)RLGL and RayMath functions exposedIncludes all symbols in raymath.h and rlgl.hIssues:Callback for logging will not workI've no good workaround for wrapping C functions with variable number of arguments.
If you know how to solve this issue, your help would be appreciated.Functions withvarargwill not workFor the reason above.Avoid string manipulation functionsFor the reason above, also because some functions involve memory allocation and manual freeing of resources. Python string methods can provide you with same and more functionality.Some examples are broken due to API changesThere was some function renaming, some changes in the examples to update to newer releases.Would you like to have a more customized binding for raylib?Again, in issue 45 I explain the actual state of this project in more detail.It my seems like bad news but actually it is the contrary.Please, take a look at this project:raylibpyctbg