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
|
import pyray
|
||||||
|
|
||||||
from raylib.colors import (
|
from pyray import (
|
||||||
RAYWHITE,
|
RAYWHITE,
|
||||||
DARKGRAY,
|
DARKGRAY,
|
||||||
RED,
|
RED,
|
||||||
|
@ -15,16 +15,12 @@ from raylib.colors import (
|
||||||
BLACK,
|
BLACK,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
MAX_BUILDINGS = 100
|
MAX_BUILDINGS = 100
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,'raylib [core] example - 2d camera')
|
||||||
'raylib [core] example - 2d camera')
|
|
||||||
|
|
||||||
player = pyray.Rectangle(400, 280, 40, 40)
|
player = pyray.Rectangle(400, 280, 40, 40)
|
||||||
buildings = []
|
buildings = []
|
||||||
|
@ -56,7 +52,6 @@ camera.zoom = 1.0
|
||||||
|
|
||||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
||||||
|
|
||||||
|
|
||||||
# Main game loop
|
# Main game loop
|
||||||
while not pyray.window_should_close(): # Detect window close button or ESC key
|
while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# Update
|
||||||
|
@ -133,6 +128,5 @@ while not pyray.window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
||||||
# De-Initialization
|
# De-Initialization
|
||||||
pyray.close_window() # Close window and OpenGL context
|
pyray.close_window() # Close window and OpenGL context
|
||||||
|
|
|
@ -6,7 +6,7 @@ raylib [core] example - 2D Camera platformer
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
|
|
||||||
import pyray
|
import pyray
|
||||||
from raylib.colors import (
|
from pyray import (
|
||||||
DARKGRAY,
|
DARKGRAY,
|
||||||
RED,
|
RED,
|
||||||
BLACK,
|
BLACK,
|
||||||
|
@ -14,8 +14,6 @@ from raylib.colors import (
|
||||||
LIGHTGRAY,
|
LIGHTGRAY,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
global g_evening_out, g_even_out_target
|
global g_evening_out, g_even_out_target
|
||||||
g_evening_out = False
|
g_evening_out = False
|
||||||
|
@ -27,8 +25,7 @@ PLAYER_HOR_SPD = 200.0
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - 2d camera')
|
||||||
'raylib [core] example - 2d camera')
|
|
||||||
|
|
||||||
|
|
||||||
# Raylib Math
|
# Raylib Math
|
||||||
|
@ -77,11 +74,11 @@ def update_player(player, env_items, delta):
|
||||||
for ei in env_items:
|
for ei in env_items:
|
||||||
p = player.position
|
p = player.position
|
||||||
if (
|
if (
|
||||||
ei.blocking and
|
ei.blocking and
|
||||||
ei.rect.x <= p.x and
|
ei.rect.x <= p.x and
|
||||||
ei.rect.x + ei.rect.width >= p.x and
|
ei.rect.x + ei.rect.width >= p.x and
|
||||||
ei.rect.y >= p.y and
|
ei.rect.y >= p.y and
|
||||||
ei.rect.y < p.y + player.speed * delta
|
ei.rect.y < p.y + player.speed * delta
|
||||||
):
|
):
|
||||||
hit_obstacle = True
|
hit_obstacle = True
|
||||||
player.speed = 0.0
|
player.speed = 0.0
|
||||||
|
@ -96,14 +93,14 @@ def update_player(player, env_items, delta):
|
||||||
|
|
||||||
|
|
||||||
def update_camera_center(
|
def update_camera_center(
|
||||||
camera, player, env_items, delta, width, height
|
camera, player, env_items, delta, width, height
|
||||||
):
|
):
|
||||||
camera.offset = pyray.Vector2(width / 2, height / 2)
|
camera.offset = pyray.Vector2(width / 2, height / 2)
|
||||||
camera.target = player.position
|
camera.target = player.position
|
||||||
|
|
||||||
|
|
||||||
def update_camera_center_inside_map(
|
def update_camera_center_inside_map(
|
||||||
camera, player, env_items, delta, width, height
|
camera, player, env_items, delta, width, height
|
||||||
):
|
):
|
||||||
camera.target = player.position
|
camera.target = player.position
|
||||||
camera.offset = pyray.Vector2(width / 2, height / 2)
|
camera.offset = pyray.Vector2(width / 2, height / 2)
|
||||||
|
@ -134,7 +131,7 @@ def update_camera_center_inside_map(
|
||||||
|
|
||||||
|
|
||||||
def update_camera_center_smooth_follow(
|
def update_camera_center_smooth_follow(
|
||||||
camera, player, env_items, delta, width, height
|
camera, player, env_items, delta, width, height
|
||||||
):
|
):
|
||||||
min_speed = 30
|
min_speed = 30
|
||||||
min_effect_length = 10
|
min_effect_length = 10
|
||||||
|
@ -152,7 +149,7 @@ def update_camera_center_smooth_follow(
|
||||||
|
|
||||||
|
|
||||||
def update_camera_even_out_on_landing(
|
def update_camera_even_out_on_landing(
|
||||||
camera, player, env_items, delta, width, height
|
camera, player, env_items, delta, width, height
|
||||||
):
|
):
|
||||||
global g_evening_out, g_even_out_target
|
global g_evening_out, g_even_out_target
|
||||||
|
|
||||||
|
@ -175,16 +172,16 @@ def update_camera_even_out_on_landing(
|
||||||
g_evening_out = False
|
g_evening_out = False
|
||||||
else:
|
else:
|
||||||
if (
|
if (
|
||||||
player.can_jump and
|
player.can_jump and
|
||||||
(player.speed == 0) and
|
(player.speed == 0) and
|
||||||
(player.position.y != camera.target.y)
|
(player.position.y != camera.target.y)
|
||||||
):
|
):
|
||||||
g_evening_out = True
|
g_evening_out = True
|
||||||
g_even_out_target = player.position.y
|
g_even_out_target = player.position.y
|
||||||
|
|
||||||
|
|
||||||
def update_camera_player_bounds_push(
|
def update_camera_player_bounds_push(
|
||||||
camera, player, env_items, delta, width, height
|
camera, player, env_items, delta, width, height
|
||||||
):
|
):
|
||||||
bbox = pyray.Vector2(0.2, 0.2)
|
bbox = pyray.Vector2(0.2, 0.2)
|
||||||
|
|
||||||
|
@ -207,11 +204,11 @@ def update_camera_player_bounds_push(
|
||||||
camera.target.y = player.position.y
|
camera.target.y = player.position.y
|
||||||
if player.position.x > bbox_world_max.x:
|
if player.position.x > bbox_world_max.x:
|
||||||
camera.target.x = (
|
camera.target.x = (
|
||||||
bbox_world_min.x + (player.position.x - bbox_world_max.x)
|
bbox_world_min.x + (player.position.x - bbox_world_max.x)
|
||||||
)
|
)
|
||||||
if player.position.y > bbox_world_max.y:
|
if player.position.y > bbox_world_max.y:
|
||||||
camera.target.y = (
|
camera.target.y = (
|
||||||
bbox_world_min.y + (player.position.y - bbox_world_max.y)
|
bbox_world_min.y + (player.position.y - bbox_world_max.y)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from raylib import Fade
|
|
||||||
import pyray
|
|
||||||
from pyray import *
|
from pyray import *
|
||||||
|
|
||||||
# Initialization
|
# 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.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.up = Vector3(0.0, 1.0, 0.0) # Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0 # Camera field-of-view Y
|
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)
|
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
|
# Main game loop
|
||||||
while not window_should_close(): # Detect window close button or ESC key
|
while not window_should_close(): # Detect window close button or ESC key
|
||||||
# Update
|
# 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)
|
camera.target = Vector3(0.0, 0.0, 0.0)
|
||||||
|
|
||||||
# Draw
|
# Draw
|
||||||
|
@ -44,7 +42,7 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
end_mode_3d()
|
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_rectangle_lines(10, 10, 320, 93, BLUE)
|
||||||
|
|
||||||
draw_text("Free camera default controls:", 20, 20, 10, BLACK)
|
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.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.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.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)
|
cube_position = pyray.Vector3(0.0, 0.0, 0.0)
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ class GameScreen(Enum):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - basic screen manager")
|
||||||
"raylib [core] example - basic screen manager")
|
|
||||||
|
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
set_target_fps(60)
|
set_target_fps(60)
|
||||||
|
|
|
@ -4,21 +4,12 @@ raylib [core] example - Basic window
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pyray
|
import pyray
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
LIGHTGRAY,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - basic window')
|
||||||
'raylib [core] example - basic window')
|
|
||||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
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
|
# Draw
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(RAYWHITE)
|
pyray.clear_background(pyray.RAYWHITE)
|
||||||
pyray.draw_text(
|
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()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -21,44 +21,37 @@ from raylib.colors import (
|
||||||
screenWidth = 800
|
screenWidth = 800
|
||||||
screenHeight = 450
|
screenHeight = 450
|
||||||
|
|
||||||
pyray.init_window(screenWidth, screenHeight,
|
pyray.init_window(screenWidth, screenHeight, 'raylib [core] example - drop files')
|
||||||
'raylib [core] example - drop files')
|
|
||||||
pyray.set_target_fps(60) # Set our game to run at 60 frames-per-second
|
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():
|
while not pyray.window_should_close():
|
||||||
|
|
||||||
if pyray.is_file_dropped():
|
if pyray.is_file_dropped():
|
||||||
droppedFiles_pointer = pyray.get_dropped_files(count_pointer)
|
droppedFiles = pyray.load_dropped_files()
|
||||||
count = count_pointer[0]
|
|
||||||
# This isn't actually necessary unless you want a Python array:
|
|
||||||
droppedFiles = pyray.ffi.unpack(droppedFiles_pointer, count)
|
|
||||||
|
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(RAYWHITE)
|
pyray.clear_background(RAYWHITE)
|
||||||
|
|
||||||
if count == 0:
|
if droppedFiles.count == 0:
|
||||||
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
pyray.draw_text("Drop your files to this window!", 100, 40, 20, DARKGRAY)
|
||||||
else:
|
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:
|
if i % 2 == 0:
|
||||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5))
|
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.5))
|
||||||
else:
|
else:
|
||||||
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3))
|
pyray.draw_rectangle(0, 85 + 40*i, screenWidth, 40, pyray.fade(LIGHTGRAY, 0.3))
|
||||||
filename = pyray.ffi.string(droppedFiles[i]).decode('utf-8')
|
pyray.draw_text(droppedFiles.paths[i], 120, 100 + 40*i, 10, GRAY)
|
||||||
# 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("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()
|
pyray.end_drawing()
|
||||||
|
|
||||||
# De-Initialization
|
# De-Initialization
|
||||||
pyray.clear_dropped_files()
|
|
||||||
pyray.close_window() # Close window and OpenGL context
|
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_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - input gestures')
|
||||||
'raylib [core] example - input gestures')
|
|
||||||
|
|
||||||
touch_position = pyray.Vector2(0, 0)
|
touch_position = pyray.Vector2(0, 0)
|
||||||
touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)
|
touch_area = pyray.Rectangle(220, 10, SCREEN_WIDTH - 230, SCREEN_HEIGHT - 20)
|
||||||
|
|
|
@ -4,21 +4,13 @@ raylib [core] example - Keyboard input
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pyray
|
import pyray
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
DARKGRAY,
|
|
||||||
MAROON,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - keyboard input')
|
||||||
'raylib [core] example - keyboard input')
|
|
||||||
ball_position = pyray.Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
|
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
|
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
|
# Draw
|
||||||
pyray.begin_drawing()
|
pyray.begin_drawing()
|
||||||
|
|
||||||
pyray.clear_background(RAYWHITE)
|
pyray.clear_background(pyray.RAYWHITE)
|
||||||
pyray.draw_text('move the ball with arrow keys', 10, 10, 20, DARKGRAY)
|
pyray.draw_text('move the ball with arrow keys', 10, 10, 20, pyray.DARKGRAY)
|
||||||
pyray.draw_circle_v(ball_position, 50, MAROON)
|
pyray.draw_circle_v(ball_position, 50, pyray.MAROON)
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -4,33 +4,13 @@ raylib [core] example - Mouse input
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
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
|
# Initialization
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - mouse input')
|
||||||
'raylib [core] example - mouse input')
|
|
||||||
|
|
||||||
ball_position = Vector2(-100, -100)
|
ball_position = Vector2(-100, -100)
|
||||||
ball_color = DARKBLUE
|
ball_color = DARKBLUE
|
||||||
|
|
|
@ -4,13 +4,6 @@ raylib [core] example - Mouse wheel input
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import pyray
|
import pyray
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
GRAY,
|
|
||||||
LIGHTGRAY,
|
|
||||||
MAROON,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,8 +12,7 @@ from raylib.colors import (
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
SCREEN_HEIGHT = 450
|
SCREEN_HEIGHT = 450
|
||||||
|
|
||||||
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT,
|
pyray.init_window(SCREEN_WIDTH, SCREEN_HEIGHT, 'raylib [core] example - input mouse wheel')
|
||||||
'raylib [core] example - input mouse wheel')
|
|
||||||
|
|
||||||
box_position_y: int = SCREEN_HEIGHT // 2 - 40
|
box_position_y: int = SCREEN_HEIGHT // 2 - 40
|
||||||
scroll_speed = 4 # Scrolling speed in pixels
|
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
|
# Draw
|
||||||
pyray.begin_drawing()
|
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!',
|
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),
|
pyray.draw_text('Box position Y: {:03d}'.format(box_position_y),
|
||||||
10, 40, 20, LIGHTGRAY)
|
10, 40, 20, pyray.LIGHTGRAY)
|
||||||
|
|
||||||
pyray.end_drawing()
|
pyray.end_drawing()
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,6 @@ raylib [core] example - random values
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
from pyray import *
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
MAROON,
|
|
||||||
LIGHTGRAY
|
|
||||||
)
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
SCREEN_WIDTH = 800
|
SCREEN_WIDTH = 800
|
||||||
|
|
|
@ -4,15 +4,7 @@ raylib [core] example - Scissor Test
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
from pyray import *
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
LIGHTGRAY,
|
|
||||||
RED,
|
|
||||||
BLACK
|
|
||||||
)
|
|
||||||
from raylib import (
|
|
||||||
KEY_S
|
|
||||||
)
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -87,4 +87,4 @@ while not window_should_close(): # Detect window close button or ESC key
|
||||||
|
|
||||||
unload_render_texture(target) # Unload render texture
|
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 pyray import *
|
||||||
|
|
||||||
from raylib import (
|
|
||||||
KEY_W,
|
|
||||||
KEY_S,
|
|
||||||
KEY_UP,
|
|
||||||
KEY_DOWN,
|
|
||||||
)
|
|
||||||
|
|
||||||
cameraPlayer1 = Camera3D([0])
|
cameraPlayer1 = Camera3D([0])
|
||||||
cameraPlayer2 = Camera3D([0])
|
cameraPlayer2 = Camera3D([0])
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,6 @@ raylib [core] example - Window Should Close
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from pyray import *
|
from pyray import *
|
||||||
from raylib.colors import (
|
|
||||||
RAYWHITE,
|
|
||||||
LIGHTGRAY,
|
|
||||||
WHITE,
|
|
||||||
BLACK
|
|
||||||
)
|
|
||||||
from raylib import (
|
|
||||||
KEY_NULL,
|
|
||||||
KEY_ESCAPE,
|
|
||||||
KEY_Y,
|
|
||||||
KEY_N
|
|
||||||
)
|
|
||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
Reference in a new issue