You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert

21
+
9
22
A python binding for the great _C_ library **[raylib](https://github.com/raysan5/raylib)**.
10
23
11
24
@@ -15,3 +28,133 @@ Plase, read this [issue](https://github.com/overdev/raylib-py/issues/45) for mor
15
28
16
29
I intend to use this repository only to make new package distribution releases.
17
30
No specific changes in the source will be made.
31
+
32
+
## Release Information:
33
+
34
+
The current release was made as output of another project, as mentioned in #45.
35
+
36
+
## Features:
37
+
- PEP8 naming convention only:
38
+
39
+
Structure attributes are in `snake_case`, classes and other types in `PascalCase`.
40
+
41
+
- Type hinting (not type annotation):
42
+
43
+
```python
44
+
defget_ray_collision_mesh(ray, mesh, transform):
45
+
# type:(Ray,Mesh,Matrix)->RayCollision
46
+
```
47
+
48
+
- structures with functions as methods and properties:
49
+
50
+
```python
51
+
sound = Sound.load('my/resorces/sound.wav') # same as load_sound(...)
52
+
position = Vector(4.0, 10.0)
53
+
54
+
# later...
55
+
sound.play() # same as play_sound(sound)
56
+
length = position.length # same as vector2length(position); uses raymath.h functions
57
+
```
58
+
59
+
- Vector{2,3,4}, Rectangle and Color have attribute swizzling;
60
+
61
+
```python
62
+
vec3 = Vector3(2.0, 5.0, 3.0)
63
+
vec2 = vec3.zxy # vec2 is a Vector2, not a sequence type
64
+
other_vec3 = vec2.xxy # same thing: other_vec3 is a Vector3
65
+
vec2.xy = vec3.y, other_vec3.z # sequences can be set as values
66
+
67
+
c_red = Color(255, 0, 0)
68
+
c_yellow = c_red.rrb
69
+
70
+
# Rectangles have aliases for width and height: w and h respectively:
71
+
rect = Rectangle(10.0, 10.0, 320.0, 240.0)
72
+
other_rect = rect.whxy # swizzling is only allowed when using four attributes, not 3 nor 2
73
+
```
74
+
75
+
- Pretty printing: most structures implement `__str__()`and`__repr__()`in a friendly way;
76
+
- Context managers: begin_*and end_* functions can be called as context managers:
77
+
78
+
Without context managers:
79
+
80
+
```python
81
+
# this example shows a rendering step
82
+
83
+
begin_drawing()
84
+
85
+
begin_texture_mode(minimap_texture)
86
+
# render the "minimap"
87
+
draw_line(2, 2, 5, 5, RED)
88
+
end_texture_mode(minimap_texture)
89
+
90
+
begin_mode2d(main_camera)
91
+
# 2d drawing logic...
92
+
draw_texture(minimap_texture, 10, 10, WHITE)
93
+
end_mode2d()
94
+
95
+
end_drawing()
96
+
```
97
+
98
+
With context managers:
99
+
100
+
```python
101
+
# this example shows a rendering step
102
+
103
+
with drawing():
104
+
105
+
with texture_mode(minimap_texture):
106
+
# render the minimap
107
+
draw_line(2, 2, 5, 5, RED)
108
+
109
+
with mode2d(main_camera):
110
+
# 2d drawing logic...
111
+
draw_texture(minimap_texture, 10, 10, WHITE)
112
+
```
113
+
114
+
- Context managers for some structures: Camera{2,3}D, Shader and others;
115
+
116
+
Folowing the example above:
117
+
```python
118
+
# this example shows a rendering step
119
+
120
+
with drawing():
121
+
122
+
with minimap_texture:
123
+
# render the minimap
124
+
draw_line(2, 2, 5, 5, RED)
125
+
126
+
with main_camera:
127
+
# 2d drawing logic...
128
+
draw_texture(minimap_texture, 10, 10, WHITE)
129
+
```
130
+
131
+
-RLGLand RayMath functions exposed
132
+
133
+
Includes all symbols in raymath.h and rlgl.h
134
+
135
+
136
+
## Issues:
137
+
- Callback for logging will not work
138
+
139
+
I've no good workaround for wrapping C functions with variable number of arguments.
140
+
If you know how to solve this issue, your help would be appreciated.
141
+
142
+
- Functions with`vararg` will not work
143
+
144
+
For the reason above.
145
+
146
+
- Avoid string manipulation functions
147
+
148
+
For 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.
149
+
150
+
- Some examples are broken due to API changes
151
+
152
+
There was some function renaming, some changes in the examples to update to newer releases.
153
+
154
+
## Would you like to have a more customized binding for raylib?
155
+
156
+
Again, in issue 45 I explain the actual state of this project in more detail.
157
+
158
+
It my seems like bad news but actually it is the contrary.
159
+
160
+
Please, take a look at this project: [raylibpyctbg](https://github.com/overdev/raylibpyctbg)
0 commit comments