8000 Merge pull request #80 from romariops/Examples/core_3d_camera_mode · sDos280/raylib-python-cffi@9ad06e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ad06e6

Browse files
Merge pull request electronstudio#80 from romariops/Examples/core_3d_camera_mode
Adding the core 3d camera mode example
2 parents 1910c11 + 982089f commit 9ad06e6

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

examples/core/core_3d_camera_mode.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
raylib [core] example - 3d camera mode
3+
adapted from https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_mode.c
4+
"""
5+
6+
import pyray
7+
8+
# Initialization
9+
SCREEN_WIDTH = 800
10+
SCREEN_HEIGHT = 450
11+
12+
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - 3d camera mode")
13+
14+
# Define the camera to look into our 3d world
15+
camera = pyray.Camera3D([0])
16+
camera.position = pyray.Vector3(0.0, 10.0, 10.0) # Camera position
17+
camera.target = pyray.Vector3(0.0, 0.0, 0.0) # Camera looking at point
18+
camera.up = pyray.Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
19+
camera.fovy = 45.0 # Camera field-of-view Y
20+
camera.projection = pyray.CAMERA_PERSPECTIVE # Camera mode type
21+
22+
cube_position = pyray.Vector3(0.0, 0.0, 0.0)
23+
24+
pyray.set_target_fps(60)
25+
26+
# Main game loop
27+
while not pyray.window_should_close():
28+
29+
# Draw
30+
pyray.begin_drawing()
31+
32+
pyray.clear_background(pyray.RAYWHITE)
33+
34+
pyray.begin_mode_3d(camera)
35+
36+
pyray.draw_cube(cube_position, 2.0, 2.0, 2.0, pyray.RED)
37+
pyray.draw_cube_wires(cube_position, 2.0, 2.0, 2.0, pyray.MAROON)
38+
39+
pyray.draw_grid(10, 1.0)
40+
41+
pyray.end_mode_3d()
42+
43+
pyray.draw_text("Welcome to the third dimension!", 10, 40, 20, pyray.DARKGRAY);
44+
45+
pyray.draw_fps(10, 10)
46+
47+
pyray.end_drawing()
48+
49+
# De-Initialization
50+
pyray.close_window()
51+

0 commit comments

Comments
 (0)
0