Пример #1
0
"""
This shows how to use the Pyray wrapper around the static binding.
"""

from raylib.pyray import PyRay
from raylib.colors import *

pyray = PyRay()

pyray.init_window(800, 450, "Raylib texture test")
pyray.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.MAP_DIFFUSE].texture = texture

pyray.unload_image(image)
pyray.set_camera_mode(camera, pyray.CAMERA_ORBITAL)

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))

while not pyray.window_should_close():
    pyray.update_camera(pyray.pointer(camera))
    pyray.begin_drawing()
Пример #2
0
            if piece.is_eaten:
                self.food.remove(piece)
                self.food.append(
                    Food(self.raylib,
                         np.random.random() * self.size - self.size / 2,
                         np.random.random() * self.size - self.size / 2))


world = World(pyray, 100, 20, 40)

pyray.init_window(800, 600, "Natural Selection")
pyray.set_target_fps(60)

# TODO: fix weird display bug

camera = pyray.Camera3D([100.0, 100.0, 100.0], [0.0, 0.0, 0.0],
                        [0.0, 1.0, 0.0], 45.0, 0)
pyray.set_camera_mode(camera, pyray.CAMERA_PERSPECTIVE)

while not pyray.window_should_close():
    pyray.update_camera(pyray.pointer(camera))
    pyray.begin_drawing()
    pyray.clear_background(RAYWHITE)
    pyray.begin_mode_3d(camera)
    world.update_and_draw()
    pyray.end_mode_3d()
    pyray.draw_fps(10, 10)
    pyray.end_drawing()
pyray.close_window()