Skip to content

Commit b9e2e8d

Browse files
committed
Lots of cool stuff:
- functions now accepts ints when floats are expected and vice-versa - vectorN, rectangle and color arguments of functions can be sequences - all structures have __str__() implemented - vectors have __getitem__() implemented with some nice tricks - basic vector math available: +, -, *, % / operators supported - setup.py is almost done (soon a wheel will be available
1 parent 6e09015 commit b9e2e8d

File tree

3 files changed

+1042
-348
lines changed

3 files changed

+1042
-348
lines changed

examples/core/core_drop_files.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# core_dropped_files.py
2+
3+
from raylibpy import *
4+
5+
def main() -> int:
6+
7+
# Initialization
8+
# -------------------------------------------------------------------------------------
9+
screen_width: int = 800
10+
screen_height: int = 450
11+
12+
init_window(screen_width, screen_height, b"raylibpy [core] example - drop files")
13+
14+
dropped_files: list = []
15+
16+
set_target_fps(60)
17+
18+
# Main game loop
19+
while not window_should_close():
20+
# Update
21+
# ---------------------------------------------------------------------------------
22+
if is_file_dropped():
23+
dropped_files = get_dropped_files()
24+
# ----------------------------------------------------------------------------------
25+
26+
# Draw
27+
# ---------------------------------------------------------------------------------
28+
begin_drawing()
29+
30+
clear_background(RAYWHITE)
31+
32+
if len(dropped_files) == 0:
33+
draw_text(b"Drop your files to this window!", 100, 40, 20, DARKGRAY)
34+
else:
35+
draw_text(b"Dropped files:", 100, 40, 20, DARKGRAY)
36+
37+
for i, drop_file in enumerate(dropped_files):
38+
if i % 2 == 0:
39+
draw_rectangle(0, 85 + 40 * i, screen_width, 40, fade(LIGHTGRAY, .5))
40+
else:
41+
draw_rectangle(0, 85 + 40 * i, screen_width, 40, fade(LIGHTGRAY, .3))
42+
43+
draw_text(drop_file, 120, 100 + 40 * i, 10, GRAY)
44+
45+
draw_text(b"Drop new files...", 100, 110 + 40 * len(dropped_files), 20, DARKGRAY)
46+
47+
end_drawing()
48+
# ---------------------------------------------------------------------------------
49+
50+
# De-Initialization
51+
# -------------------------------------------------------------------------------------
52+
close_window()
53+
# -------------------------------------------------------------------------------------
54+
55+
return 0
56+
57+
58+
if __name__ == '__main__':
59+
main()

0 commit comments

Comments
 (0)