Closed carlsmith closed 5 years ago
@carlsmith This happens to me with the same code, but the calls work if you initialize the lib first. Try something like this:
#!/usr/bin/python
import os, sys
os.environ['RAYLIB_BIN_PATH'] = '/usr/lib/'
import raylibpy as raylib
raylib.init_window(800,600, 'Test')
raylib.set_target_fps(60)
while not raylib.window_should_close():
raylib.begin_drawing()
raylib.clear_background(raylib.LIGHTGRAY)
raylib.end_drawing()
raylib.close_window()
Ahhh, that makes sense. Thanks, @flipcoder.
An example like that should probably in the README. If your example added a call to draw_text
after clear_background
, like the official core_basic_window
example does, it would be ideal for illustrating how to translate the C examples to Python.
Something like this:
import raylibpy as raylib
window_width, window_height = 800, 450
window_title = "Raylib's Basic Window Example in Python"
raylib.init_window(window_width, window_height, window_title)
raylib.set_target_fps(60)
message = "Congrats! You created your first window!"
while not raylib.window_should_close():
raylib.begin_drawing()
raylib.clear_background(raylib.RAYWHITE)
raylib.draw_text(message, 190, 200, 20, raylib.LIGHTGRAY)
raylib.end_drawing()
raylib.close_window()
I just tried running this code:
It exited with
Segmentation fault: 11
(on macOS 10.14.3). I tried it with my copy ofraylib
and the bundled one, with the same result.