QOL docs, colors, version number, example imports

This commit is contained in:
richard 2021-10-04 15:56:29 +01:00
parent 9e17046408
commit 50c2fb12e2
13 changed files with 102 additions and 66 deletions

View file

@ -2,47 +2,47 @@
This shows how to use the Pyray wrapper around the static binding.
"""
from raylib.pyray import PyRay
from raylib.colors import *
import raylib
pyray = PyRay()
pyray.init_window(800, 450, "Raylib texture test")
pyray.set_target_fps(60)
pr = raylib.PyRay()
image = pyray.gen_image_color(800, 400, (0,0,0,255) )
texture = pyray.load_texture_from_image(image)
pyray.update_texture(texture, image.data)
pr.init_window(800, 450, "Raylib texture test")
pr.set_target_fps(60)
camera = pyray.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
image = pyray.load_image("examples/models/resources/heightmap.png")
texture = pyray.load_texture_from_image(image)
mesh = pyray.gen_mesh_heightmap(image, (16, 8, 16))
model = pyray.load_model_from_mesh(mesh)
model.materials.maps[pyray.MATERIAL_MAP_DIFFUSE].texture = texture
image = pr.gen_image_color(800, 400, (0,0,0,255) )
texture = pr.load_texture_from_image(image)
pr.update_texture(texture, image.data)
pyray.unload_image(image)
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)
camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0)
image = pr.load_image("examples/models/resources/heightmap.png")
texture = pr.load_texture_from_image(image)
mesh = pr.gen_mesh_heightmap(image, (16, 8, 16))
model = pr.load_model_from_mesh(mesh)
model.materials.maps[pr.MATERIAL_MAP_DIFFUSE].texture = texture
pos = pyray.get_mouse_position()
ray = pyray.get_mouse_ray(pos, camera)
rayhit = pyray.get_collision_ray_ground(ray, 0)
pr.unload_image(image)
pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
print(str(rayhit.position.x))
while not pyray.window_should_close():
pyray.update_camera(camera)
pyray.begin_drawing()
pyray.clear_background(RAYWHITE)
pyray.begin_mode_3d(camera)
pyray.draw_model(model, (-8.0, 0.0, -8.0), 1.0, RED)
pyray.draw_grid(20, 1.0)
pyray.end_mode_3d()
pyray.draw_text("This mesh should be textured", 190, 200, 20, VIOLET)
pyray.end_drawing()
while not pr.window_should_close():
pr.update_camera(camera)
pr.begin_drawing()
pr.clear_background(pr.RAYWHITE)
pr.begin_mode_3d(camera)
pr.draw_model(model, (-8.0, 0.0, -8.0), 1.0, pr.RED)
pr.draw_grid(20, 1.0)
pr.end_mode_3d()
pr.draw_text("This mesh should be textured", 190, 200, 20, pr.VIOLET)
pr.end_drawing()
pos = pyray.get_mouse_position()
ray = pyray.get_mouse_ray(pos, camera)
rayhit = pyray.get_collision_ray_ground(ray, 0)
print(str(rayhit.position.x))
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
#print(str(rayhit.position.x))
pyray.close_window()
pr.close_window()