update core examples
This commit is contained in:
parent
83b810b1eb
commit
eb68dec2ad
17 changed files with 52 additions and 214 deletions
|
@ -21,44 +21,37 @@ from raylib.colors import (
|
|||
screenWidth = 800
|
||||
screenHeight = 450
|
||||
|
||||
pyray.init_window(screenWidth, screenHeight,
|
||||
'raylib [core] example - drop files')
|
||||
pyray.init_window(screenWidth, screenHeight, 'raylib [core] example - drop files')
|
||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||
|
||||
droppedFiles = pyray.FilePathList()
|
||||
|
||||
|
||||
count_pointer = pyray.ffi.new("int *", 0)
|
||||
count = 0
|
||||
|
||||
while not pyray.window_should_close():
|
||||
|
||||
if pyray.is_file_dropped():
|
||||
droppedFiles_pointer = pyray.get_dropped_files(count_pointer)
|
||||
count = count_pointer[0]
|
||||
# This isn't actually necessary unless you want a Python array:
|
||||
droppedFiles = pyray.ffi.unpack(droppedFiles_pointer, count)
|
||||
droppedFiles = pyray.load_dropped_files()
|
||||
|
||||
|
||||
pyray.begin_drawing()
|
||||
|
||||
pyray.clear_background(RAYWHITE)
|
||||
|
||||
if count == 0:
|
||||
if droppedFiles.count == 0:
|
||||
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
||||
else:
|
||||
pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY);
|
||||
pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY)
|
||||
|
||||
for i in range(0, count):
|
||||
for i in range(0, droppedFiles.count):
|
||||
if i % 2 == 0:
|
||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5))
|
||||
else:
|
||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3))
|
||||
filename = pyray.ffi.string(droppedFiles[i]).decode('utf-8')
|
||||
# This alternative works too if you don't have a Python array:
|
||||
# filename = pyray.ffi.string(droppedFiles_pointer[i]).decode('utf-8')
|
||||
pyray.draw_text(filename, 120, 100 + 40*i, 10, GRAY)
|
||||
pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY)
|
||||
|
||||
pyray.draw_text("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY);
|
||||
pyray.draw_text("Drop new files...", 100, 110 + 40*droppedFiles.count, 20, DARKGRAY)
|
||||
pyray.end_drawing()
|
||||
|
||||
# De-Initialization
|
||||
pyray.clear_dropped_files()
|
||||
pyray.close_window() # Close window and OpenGL context
|
||||
|
|
Reference in a new issue