update core examples
This commit is contained in:
parent
83b810b1eb
commit
eb68dec2ad
17 changed files with 52 additions and 214 deletions
|
@ -5,7 +5,7 @@ raylib [core] example - 2D Camera System
|
|||
"""
|
||||
import pyray
|
||||
|
||||
from raylib.colors import (
|
||||
from pyray import (
|
||||
RAYWHITE,
|
||||
DARKGRAY,
|
||||
RED,
|
||||
|
@ -15,16 +15,12 @@ from raylib.colors import (
|
|||
BLACK,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
# Initialization
|
||||
MAX_BUILDINGS = 100
|
||||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - 2d camera')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,'raylib [core] example - 2d camera')
|
||||
|
||||
player = pyray.Rectangle(400, 280, 40, 40)
|
||||
buildings = []
|
||||
|
@ -56,7 +52,6 @@ camera.zoom = 1.0
|
|||
|
||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||
|
||||
|
||||
# Main game loop
|
||||
while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||
# Update
|
||||
|
@ -133,6 +128,5 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
|||
|
||||
pyray.end_drawing()
|
||||
|
||||
|
||||
# De-Initialization
|
||||
pyray.close_window() # Close window and OpenGL context
|
||||
|
|
|
@ -6,7 +6,7 @@ raylib [core] example - 2D Camera platformer
|
|||
from math import sqrt
|
||||
|
||||
import pyray
|
||||
from raylib.colors import (
|
||||
from pyray import (
|
||||
DARKGRAY,
|
||||
RED,
|
||||
BLACK,
|
||||
|
@ -14,8 +14,6 @@ from raylib.colors import (
|
|||
LIGHTGRAY,
|
||||
)
|
||||
|
||||
|
||||
|
||||
# Initialization
|
||||
global g_evening_out, g_even_out_target
|
||||
g_evening_out = False
|
||||
|
@ -27,8 +25,7 @@ PLAYER_HOR_SPD = 200.0
|
|||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - 2d camera')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - 2d camera')
|
||||
|
||||
|
||||
# Raylib Math
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from raylib import Fade
|
||||
import pyray
|
||||
from pyray import *
|
||||
|
||||
# Initialization
|
||||
|
@ -14,7 +12,7 @@ camera.position = Vector3(10.0, 10.0, 10.0) # Camera position
|
|||
camera.target = Vector3(0.0, 0.0, 0.0) # Camera looking at point
|
||||
camera.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0 # Camera field-of-view Y
|
||||
camera.projection = pyray.CAMERA_PERSPECTIVE # Camera projection type
|
||||
camera.projection = CameraProjection.CAMERA_PERSPECTIVE # Camera projection type
|
||||
|
||||
cubePosition = Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
@ -25,9 +23,9 @@ set_target_fps(60) # Set our game to run at 60 frames-per-second
|
|||
# Main game loop
|
||||
while not window_should_close(): # Detect window close button or ESC key
|
||||
# Update
|
||||
update_camera(camera, pyray.CAMERA_FREE)
|
||||
update_camera(camera, CameraMode.CAMERA_FREE)
|
||||
|
||||
if is_key_pressed(pyray.KEY_Z):
|
||||
if is_key_pressed(KEY_Z):
|
||||
camera.target = Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
# Draw
|
||||
|
@ -44,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
|||
|
||||
end_mode_3d()
|
||||
|
||||
draw_rectangle(10, 10, 320, 93, Fade(SKYBLUE, 0.5))
|
||||
draw_rectangle(10, 10, 320, 93, fade(SKYBLUE, 0.5))
|
||||
draw_rectangle_lines(10, 10, 320, 93, BLUE)
|
||||
|
||||
draw_text("Free camera default controls:", 20, 20, 10, BLACK)
|
||||
|
|
|
@ -17,7 +17,7 @@ camera.position = pyray.Vector3(0.0, 10.0, 10.0) # Camera position
|
|||
camera.target = pyray.Vector3(0.0, 0.0, 0.0) # Camera looking at point
|
||||
camera.up = pyray.Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
|
||||
camera.fovy = 45.0 # Camera field-of-view Y
|
||||
camera.projection = pyray.CAMERA_PERSPECTIVE # Camera mode type
|
||||
camera.projection = pyray.CameraProjection.CAMERA_PERSPECTIVE # Camera mode type
|
||||
|
||||
cube_position = pyray.Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@ class GameScreen(Enum):
|
|||
|
||||
|
||||
def main():
|
||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
"raylib [core] example - basic screen manager")
|
||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - basic screen manager")
|
||||
|
||||
frame_count = 0
|
||||
set_target_fps(60)
|
||||
|
|
|
@ -4,21 +4,12 @@ raylib [core] example - Basic window
|
|||
|
||||
"""
|
||||
import pyray
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
LIGHTGRAY,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Initialization
|
||||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - basic window')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - basic window')
|
||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||
|
||||
|
||||
|
@ -30,9 +21,9 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
|||
# Draw
|
||||
pyray.begin_drawing()
|
||||
|
||||
pyray.clear_background(RAYWHITE)
|
||||
pyray.clear_background(pyray.RAYWHITE)
|
||||
pyray.draw_text(
|
||||
'Congrats! You created your first window!', 190, 200, 20, LIGHTGRAY)
|
||||
'Congrats! You created your first window!', 190, 200, 20, pyray.LIGHTGRAY)
|
||||
|
||||
pyray.end_drawing()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
"""
|
||||
|
||||
* raylib [core] example - Windows drop files
|
||||
*
|
||||
* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?)
|
||||
*
|
||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
|
||||
"""
|
||||
import pyray
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
DARKGRAY,
|
||||
LIGHTGRAY,
|
||||
GRAY
|
||||
)
|
||||
|
||||
screenWidth = 800
|
||||
screenHeight = 450
|
||||
|
||||
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 = []
|
||||
|
||||
def get_dropped_files():
|
||||
count_pointer = pyray.ffi.new("int *", 0)
|
||||
droppedFiles_pointer = pyray.get_dropped_files(count_pointer)
|
||||
d = []
|
||||
for i in range(0, count_pointer[0]):
|
||||
d.append(pyray.ffi.string(droppedFiles_pointer[i]).decode('utf-8'))
|
||||
return d
|
||||
|
||||
|
||||
while not pyray.window_should_close():
|
||||
|
||||
if pyray.is_file_dropped():
|
||||
droppedFiles = get_dropped_files()
|
||||
|
||||
pyray.begin_drawing()
|
||||
|
||||
pyray.clear_background(RAYWHITE)
|
||||
|
||||
if len(droppedFiles) == 0:
|
||||
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
||||
else:
|
||||
pyray.draw_text("Dropped files:", 100, 40, 20, DARKGRAY);
|
||||
|
||||
for i in range(0, len(droppedFiles)):
|
||||
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))
|
||||
pyray.draw_text(droppedFiles[i], 120, 100 + 40*i, 10, GRAY)
|
||||
|
||||
pyray.draw_text("Drop new files...", 100, 110 + 40*len(droppedFiles), 20, DARKGRAY);
|
||||
pyray.end_drawing()
|
||||
|
||||
# De-Initialization
|
||||
pyray.clear_dropped_files()
|
||||
pyray.close_window() # Close window and OpenGL context
|
|
@ -19,8 +19,7 @@ MAX_GESTURE_STRINGS = 20
|
|||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - input gestures')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - input gestures')
|
||||
|
||||
touch_position = pyray.Vector2(0, 0)
|
||||
touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)
|
||||
|
|
|
@ -4,21 +4,13 @@ raylib [core] example - Keyboard input
|
|||
|
||||
"""
|
||||
import pyray
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
DARKGRAY,
|
||||
MAROON,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
# Initialization
|
||||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - keyboard input')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - keyboard input')
|
||||
ball_position = pyray.Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
|
||||
|
||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||
|
@ -39,9 +31,9 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
|||
# Draw
|
||||
pyray.begin_drawing()
|
||||
|
||||
pyray.clear_background(RAYWHITE)
|
||||
pyray.draw_text('move the ball with arrow keys', 10, 10, 20, DARKGRAY)
|
||||
pyray.draw_circle_v(ball_position, 50, MAROON)
|
||||
pyray.clear_background(pyray.RAYWHITE)
|
||||
pyray.draw_text('move the ball with arrow keys', 10, 10, 20, pyray.DARKGRAY)
|
||||
pyray.draw_circle_v(ball_position, 50, pyray.MAROON)
|
||||
|
||||
pyray.end_drawing()
|
||||
|
||||
|
|
|
@ -4,33 +4,13 @@ raylib [core] example - Mouse input
|
|||
|
||||
"""
|
||||
from pyray import *
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
DARKGRAY,
|
||||
MAROON,
|
||||
LIME,
|
||||
DARKBLUE,
|
||||
PURPLE,
|
||||
YELLOW,
|
||||
ORANGE,
|
||||
BEIGE,
|
||||
)
|
||||
from raylib import (
|
||||
MOUSE_BUTTON_LEFT,
|
||||
MOUSE_BUTTON_MIDDLE,
|
||||
MOUSE_BUTTON_RIGHT,
|
||||
MOUSE_BUTTON_SIDE,
|
||||
MOUSE_BUTTON_EXTRA,
|
||||
MOUSE_BUTTON_FORWARD,
|
||||
MOUSE_BUTTON_BACK
|
||||
)
|
||||
|
||||
|
||||
# Initialization
|
||||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - mouse input')
|
||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - mouse input')
|
||||
|
||||
ball_position = Vector2(-100, -100)
|
||||
ball_color = DARKBLUE
|
||||
|
|
|
@ -4,13 +4,6 @@ raylib [core] example - Mouse wheel input
|
|||
|
||||
"""
|
||||
import pyray
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
GRAY,
|
||||
LIGHTGRAY,
|
||||
MAROON,
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,8 +12,7 @@ from raylib.colors import (
|
|||
SCREEN_WIDTH = 800
|
||||
SCREEN_HEIGHT = 450
|
||||
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
'raylib [core] example - input mouse wheel')
|
||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - input mouse wheel')
|
||||
|
||||
box_position_y: int = SCREEN_HEIGHT // 2 - 40
|
||||
scroll_speed = 4 # Scrolling speed in pixels
|
||||
|
@ -36,14 +28,14 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
|||
# Draw
|
||||
pyray.begin_drawing()
|
||||
|
||||
pyray.clear_background(RAYWHITE)
|
||||
pyray.clear_background(pyray.RAYWHITE)
|
||||
|
||||
pyray.draw_rectangle(SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, MAROON)
|
||||
pyray.draw_rectangle(SCREEN_WIDTH // 2 - 40, box_position_y, 80, 80, pyray.MAROON)
|
||||
|
||||
pyray.draw_text('User mouse wheel to move the cube up and down!',
|
||||
10, 10, 20, GRAY)
|
||||
10, 10, 20, pyray.GRAY)
|
||||
pyray.draw_text('Box position Y: {:03d}'.format(box_position_y),
|
||||
10, 40, 20, LIGHTGRAY)
|
||||
10, 40, 20, pyray.LIGHTGRAY)
|
||||
|
||||
pyray.end_drawing()
|
||||
|
||||
|
|
|
@ -4,11 +4,6 @@ raylib [core] example - random values
|
|||
|
||||
"""
|
||||
from pyray import *
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
MAROON,
|
||||
LIGHTGRAY
|
||||
)
|
||||
|
||||
# Initialization
|
||||
SCREEN_WIDTH = 800
|
||||
|
|
|
@ -4,15 +4,7 @@ raylib [core] example - Scissor Test
|
|||
|
||||
"""
|
||||
from pyray import *
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
LIGHTGRAY,
|
||||
RED,
|
||||
BLACK
|
||||
)
|
||||
from raylib import (
|
||||
KEY_S
|
||||
)
|
||||
|
||||
|
||||
# Initialization
|
||||
# --------------------------------------------------------------------------------------
|
||||
|
|
|
@ -87,4 +87,4 @@ while not window_should_close(): # Detect window close button or ESC key
|
|||
|
||||
unload_render_texture(target) # Unload render texture
|
||||
|
||||
close_window(); # Close window and OpenGL context
|
||||
close_window() # Close window and OpenGL context
|
|
@ -6,13 +6,6 @@ raylib [core] example - Split Screen
|
|||
|
||||
from pyray import *
|
||||
|
||||
from raylib import (
|
||||
KEY_W,
|
||||
KEY_S,
|
||||
KEY_UP,
|
||||
KEY_DOWN,
|
||||
)
|
||||
|
||||
cameraPlayer1 = Camera3D([0])
|
||||
cameraPlayer2 = Camera3D([0])
|
||||
|
||||
|
|
|
@ -4,18 +4,6 @@ raylib [core] example - Window Should Close
|
|||
|
||||
"""
|
||||
from pyray import *
|
||||
from raylib.colors import (
|
||||
RAYWHITE,
|
||||
LIGHTGRAY,
|
||||
WHITE,
|
||||
BLACK
|
||||
)
|
||||
from raylib import (
|
||||
KEY_NULL,
|
||||
KEY_ESCAPE,
|
||||
KEY_Y,
|
||||
KEY_N
|
||||
)
|
||||
|
||||
# Initialization
|
||||
# --------------------------------------------------------------------------------------
|
||||
|
|
Reference in a new issue