generate h files on linux and then use them on windows
This commit is contained in:
parent
10545a2f37
commit
ef2d56308a
16 changed files with 2533 additions and 384 deletions
49
tests/raygui_test.py
Normal file
49
tests/raygui_test.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from raylib import *
|
||||
import pyray as pr
|
||||
|
||||
screenWidth = 800
|
||||
screenHeight = 600
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_UNDECORATED)
|
||||
InitWindow(screenWidth, screenHeight, b"raygui - portable window")
|
||||
|
||||
|
||||
mousePosition = pr.Vector2(0, 0)
|
||||
windowPosition = pr.Vector2(500, 200 )
|
||||
panOffset = mousePosition
|
||||
dragWindow = False
|
||||
|
||||
SetWindowPosition(int(windowPosition.x), int(windowPosition.y))
|
||||
|
||||
exitWindow = False
|
||||
|
||||
SetTargetFPS(60)
|
||||
|
||||
|
||||
while not exitWindow and not WindowShouldClose():
|
||||
|
||||
mousePosition = GetMousePosition()
|
||||
|
||||
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT):
|
||||
if CheckCollisionPointRec(mousePosition, pr.Rectangle(0, 0, screenWidth, 20) ):
|
||||
dragWindow = True
|
||||
panOffset = mousePosition
|
||||
|
||||
|
||||
|
||||
if (dragWindow):
|
||||
windowPosition.x += (mousePosition.x - panOffset.x)
|
||||
windowPosition.y += (mousePosition.y - panOffset.y)
|
||||
if IsMouseButtonReleased(MOUSE_BUTTON_LEFT):
|
||||
dragWindow = False
|
||||
|
||||
SetWindowPosition(int(windowPosition.x), int(windowPosition.y))
|
||||
|
||||
|
||||
BeginDrawing()
|
||||
ClearBackground(RAYWHITE)
|
||||
exitWindow = GuiWindowBox(pr.Rectangle(0, 0, screenWidth, screenHeight) , b"#198# PORTABLE WINDOW")
|
||||
pr.draw_text(f"Mouse Position: {mousePosition.x} {mousePosition.y}", 10, 40, 10, DARKGRAY)
|
||||
EndDrawing()
|
||||
|
||||
CloseWindow()
|
70
tests/test_physac.py
Normal file
70
tests/test_physac.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
from raylib import *
|
||||
|
||||
screenWidth = 800
|
||||
screenHeight = 450
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT)
|
||||
InitWindow(screenWidth, screenHeight, b"[physac] Basic demo")
|
||||
|
||||
|
||||
logoX = screenWidth - MeasureText(b"Physac", 30) - 10
|
||||
logoY = 15
|
||||
|
||||
|
||||
InitPhysics()
|
||||
|
||||
|
||||
floor = CreatePhysicsBodyRectangle([screenWidth/2, screenHeight ], 500, 100, 10)
|
||||
floor.enabled = False
|
||||
|
||||
|
||||
circle = CreatePhysicsBodyCircle([screenWidth/2, screenHeight/2], 45, 10)
|
||||
circle.enabled = False
|
||||
|
||||
SetTargetFPS(60)
|
||||
|
||||
while not WindowShouldClose():
|
||||
|
||||
UpdatePhysics();
|
||||
|
||||
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT):
|
||||
body = CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10)
|
||||
|
||||
elif IsMouseButtonPressed(MOUSE_BUTTON_RIGHT):
|
||||
CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10)
|
||||
|
||||
|
||||
bodiesCount = GetPhysicsBodiesCount()
|
||||
for i in range(bodiesCount):
|
||||
body = GetPhysicsBody(i)
|
||||
if body and (body.position.y > screenHeight*2):
|
||||
DestroyPhysicsBody(body)
|
||||
|
||||
|
||||
BeginDrawing()
|
||||
ClearBackground(BLACK)
|
||||
DrawFPS(screenWidth - 90, screenHeight - 30)
|
||||
|
||||
|
||||
bodiesCount = GetPhysicsBodiesCount()
|
||||
for i in range(bodiesCount):
|
||||
body = GetPhysicsBody(i)
|
||||
if body:
|
||||
vertexCount = GetPhysicsShapeVerticesCount(i)
|
||||
for j in range(vertexCount):
|
||||
vertexA = GetPhysicsShapeVertex(body, j)
|
||||
jj = j + 1 if (j + 1) < vertexCount else 0
|
||||
vertexB = GetPhysicsShapeVertex(body, jj)
|
||||
DrawLineV(vertexA, vertexB, GREEN)
|
||||
|
||||
DrawText(b"Left mouse button to create a polygon", 10, 10, 10, WHITE)
|
||||
DrawText(b"Right mouse button to create a circle", 10, 25, 10, WHITE)
|
||||
|
||||
DrawText(b"Physac", logoX, logoY, 30, WHITE)
|
||||
DrawText(b"Powered by", logoX + 50, logoY - 7, 10, WHITE)
|
||||
|
||||
EndDrawing()
|
||||
|
||||
ClosePhysics()
|
||||
|
||||
CloseWindow()
|
76
tests/test_physac2.py
Normal file
76
tests/test_physac2.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
from raylib import *
|
||||
|
||||
VELOCITY = 0.5
|
||||
|
||||
screenWidth = 800
|
||||
screenHeight = 450
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT)
|
||||
InitWindow(screenWidth, screenHeight, b"[physac] Basic demo")
|
||||
logoX = screenWidth - MeasureText(b"Physac", 30) - 10
|
||||
logoY = 15
|
||||
|
||||
|
||||
InitPhysics()
|
||||
|
||||
floor = CreatePhysicsBodyRectangle([screenWidth/2, screenHeight ], screenWidth, 100, 10)
|
||||
platformLeft = CreatePhysicsBodyRectangle([screenWidth*0.25, screenHeight*0.6 ], screenWidth*0.25, 10, 10)
|
||||
platformRight = CreatePhysicsBodyRectangle([screenWidth*0.75, screenHeight*0.6 ], screenWidth*0.25, 10, 10)
|
||||
wallLeft = CreatePhysicsBodyRectangle([-5, screenHeight/2 ], 10, screenHeight, 10)
|
||||
wallRight = CreatePhysicsBodyRectangle([screenWidth + 5, screenHeight/2 ], 10, screenHeight, 10)
|
||||
|
||||
|
||||
floor.enabled = False
|
||||
platformLeft.enabled = False
|
||||
platformRight.enabled = False
|
||||
wallLeft.enabled = False
|
||||
wallRight.enabled = False
|
||||
|
||||
|
||||
body = CreatePhysicsBodyRectangle([screenWidth/2, screenHeight/2 ], 50, 50, 1)
|
||||
body.freezeOrient = True
|
||||
|
||||
SetTargetFPS(60)
|
||||
|
||||
while not WindowShouldClose():
|
||||
|
||||
UpdatePhysics();
|
||||
|
||||
if IsKeyDown(KEY_RIGHT):
|
||||
body.velocity.x = VELOCITY
|
||||
elif IsKeyDown(KEY_LEFT):
|
||||
body.velocity.x = -VELOCITY
|
||||
|
||||
|
||||
if IsKeyDown(KEY_UP) and body.isGrounded:
|
||||
body.velocity.y = -VELOCITY*4
|
||||
|
||||
BeginDrawing()
|
||||
|
||||
ClearBackground(BLACK)
|
||||
|
||||
DrawFPS(screenWidth - 90, screenHeight - 30)
|
||||
|
||||
|
||||
bodiesCount = GetPhysicsBodiesCount()
|
||||
for i in range(bodiesCount):
|
||||
body = GetPhysicsBody(i)
|
||||
vertexCount = GetPhysicsShapeVerticesCount(i)
|
||||
for j in range(vertexCount):
|
||||
vertexA = GetPhysicsShapeVertex(body, j)
|
||||
|
||||
jj = j + 1 if j + 1 < vertexCount else 0
|
||||
vertexB = GetPhysicsShapeVertex(body, jj)
|
||||
|
||||
DrawLineV(vertexA, vertexB, GREEN)
|
||||
|
||||
DrawText(b"Use 'ARROWS' to move player", 10, 10, 10, WHITE)
|
||||
|
||||
DrawText(b"Physac", logoX, logoY, 30, WHITE)
|
||||
DrawText(b"Powered by", logoX + 50, logoY - 7, 10, WHITE)
|
||||
|
||||
EndDrawing()
|
||||
|
||||
ClosePhysics()
|
||||
|
||||
CloseWindow()
|
7
tests/test_rlgl.py
Normal file
7
tests/test_rlgl.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from raylib import *
|
||||
|
||||
InitWindow(800, 450, b"rlGL test")
|
||||
SetTargetFPS(60)
|
||||
|
||||
|
||||
print(rlGetVersion())
|
Reference in a new issue