Skip to content

Commit 98073f9

Browse files
author
Jorge A. Gomes
committed
readme updated to include release features
1 parent d5e38c1 commit 98073f9

File tree

1 file changed

+145
-2
lines changed

1 file changed

+145
-2
lines changed

README.md

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44

55
# raylib-py
66

7-
[![Downloads](https://pepy.tech/badge/raylib-py)](https://pepy.tech/project/raylib-py)
8-
[![Downloads](https://pepy.tech/badge/raylib-py/month)](https://pepy.tech/project/raylib-py)
7+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/raylib-py?style=plastic)
8+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/overdev/raylib-py?style=plastic)
9+
![GitHub Release Date](https://img.shields.io/github/release-date/overdev/raylib-py?style=plastic)
10+
11+
![PyPI - Wheel](https://img.shields.io/pypi/wheel/raylib-py?style=plastic)
12+
![PyPI - License](https://img.shields.io/pypi/l/raylib-py?style=plastic)
13+
![PyPI - Downloads](https://img.shields.io/pypi/dd/raylib-py?label=PyPI%20Downloads&style=plastic)
14+
15+
![GitHub all releases](https://img.shields.io/github/downloads/overdev/raylib-py/total?style=plastic)
16+
![GitHub release (by tag)](https://img.shields.io/github/downloads/overdev/raylib-py/v4.2.0/total?style=plastic)
17+
![GitHub forks](https://img.shields.io/github/forks/overdev/raylib-py?style=social)
18+
19+
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/overdev/raylib-py?style=plastic)
20+
![GitHub commits since tagged version](https://img.shields.io/github/commits-since/overdev/raylib-py/v4.2.0?style=plastic)
21+
922
A python binding for the great _C_ library **[raylib](https://github.com/raysan5/raylib)**.
1023

1124

@@ -15,3 +28,133 @@ Plase, read this [issue](https://github.com/overdev/raylib-py/issues/45) for mor
1528

1629
I intend to use this repository only to make new package distribution releases.
1730
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+
def get_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+
- RLGL and 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

Comments
 (0)