update to raylib 4.0-dev and add physac and raygui

This commit is contained in:
richard 2021-10-08 17:36:08 +01:00
parent 8c4d2af2dc
commit 5f28d0101a
13 changed files with 1088 additions and 612 deletions

View file

@ -23,7 +23,7 @@ pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
rayhit = pr.get_ray_collision_ground(ray, 0)
print(str(rayhit.position.x))
while not pr.window_should_close():
@ -39,7 +39,7 @@ while not pr.window_should_close():
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
rayhit = pr.get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
pr.close_window()

49
portable_window.py Normal file
View 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_LEFT_BUTTON):
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_LEFT_BUTTON):
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()

@ -1 +1 @@
Subproject commit b6c8d343dca2ef19c23c50975328a028124cf3cb
Subproject commit 33ed452439a6b28a39f190714e18ee5dcb2e7673

View file

@ -27,9 +27,16 @@ ffibuilder = FFI()
def build_linux():
print("BUILDING FOR LINUX")
ffibuilder.cdef(open("raylib/raylib_modified.h").read().replace('RLAPI ', ''))
ffibuilder.cdef(open("raylib/raygui_modified.h").read().replace('RAYGUIDEF ', ''))
ffibuilder.cdef(open("raylib/physac_modified.h").read().replace('PHYSACDEF ', ''))
ffibuilder.set_source("raylib._raylib_cffi",
"""
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#define RAYGUI_SUPPORT_RICONS
#include "../raylib-c/src/extras/raygui.h"
#define PHYSAC_IMPLEMENTATION
#include "../raylib-c/src/extras/physac.h"
""",
extra_link_args=['/usr/local/lib/libraylib.a','-lm', '-lpthread', '-lGLU', '-lGL', '-lrt', '-lm', '-ldl', '-lX11', '-lpthread'],
libraries=['GL','m','pthread', 'dl', 'rt', 'X11']

98
raylib/physac_modified.h Normal file
View file

@ -0,0 +1,98 @@
#define PHYSAC_MAX_BODIES 64 // Maximum number of physic bodies supported
#define PHYSAC_MAX_MANIFOLDS 4096 // Maximum number of physic bodies interactions (64x64)
#define PHYSAC_MAX_VERTICES 24 // Maximum number of vertex for polygons shapes
#define PHYSAC_DEFAULT_CIRCLE_VERTICES 24 // Default number of vertices for circle shapes
typedef enum PhysicsShapeType { PHYSICS_CIRCLE = 0, PHYSICS_POLYGON } PhysicsShapeType;
// Previously defined to be used in PhysicsShape struct as circular dependencies
typedef struct PhysicsBodyData *PhysicsBody;
// Matrix2x2 type (used for polygon shape rotation matrix)
typedef struct Matrix2x2 {
float m00;
float m01;
float m10;
float m11;
} Matrix2x2;
typedef struct PhysicsVertexData {
unsigned int vertexCount; // Vertex count (positions and normals)
Vector2 positions[PHYSAC_MAX_VERTICES]; // Vertex positions vectors
Vector2 normals[PHYSAC_MAX_VERTICES]; // Vertex normals vectors
} PhysicsVertexData;
typedef struct PhysicsShape {
PhysicsShapeType type; // Shape type (circle or polygon)
PhysicsBody body; // Shape physics body data pointer
PhysicsVertexData vertexData; // Shape vertices data (used for polygon shapes)
float radius; // Shape radius (used for circle shapes)
Matrix2x2 transform; // Vertices transform matrix 2x2
} PhysicsShape;
typedef struct PhysicsBodyData {
unsigned int id; // Unique identifier
bool enabled; // Enabled dynamics state (collisions are calculated anyway)
Vector2 position; // Physics body shape pivot
Vector2 velocity; // Current linear velocity applied to position
Vector2 force; // Current linear force (reset to 0 every step)
float angularVelocity; // Current angular velocity applied to orient
float torque; // Current angular force (reset to 0 every step)
float orient; // Rotation in radians
float inertia; // Moment of inertia
float inverseInertia; // Inverse value of inertia
float mass; // Physics body mass
float inverseMass; // Inverse value of mass
float staticFriction; // Friction when the body has not movement (0 to 1)
float dynamicFriction; // Friction when the body has movement (0 to 1)
float restitution; // Restitution coefficient of the body (0 to 1)
bool useGravity; // Apply gravity force to dynamics
bool isGrounded; // Physics grounded on other body state
bool freezeOrient; // Physics rotation constraint
PhysicsShape shape; // Physics body shape information (type, radius, vertices, transform)
} PhysicsBodyData;
typedef struct PhysicsManifoldData {
unsigned int id; // Unique identifier
PhysicsBody bodyA; // Manifold first physics body reference
PhysicsBody bodyB; // Manifold second physics body reference
float penetration; // Depth of penetration from collision
Vector2 normal; // Normal direction vector from 'a' to 'b'
Vector2 contacts[2]; // Points of contact during collision
unsigned int contactsCount; // Current collision number of contacts
float restitution; // Mixed restitution during collision
float dynamicFriction; // Mixed dynamic friction during collision
float staticFriction; // Mixed static friction during collision
} PhysicsManifoldData, *PhysicsManifold;
PHYSACDEF void InitPhysics(void); // Initializes physics system
PHYSACDEF void UpdatePhysics(void); // Update physics system
PHYSACDEF void ResetPhysics(void); // Reset physics system (global variables)
PHYSACDEF void ClosePhysics(void); // Close physics system and unload used memory
PHYSACDEF void SetPhysicsTimeStep(double delta); // Sets physics fixed time step in milliseconds. 1.666666 by default
PHYSACDEF void SetPhysicsGravity(float x, float y); // Sets physics global gravity force
// Physic body creation/destroy
PHYSACDEF PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); // Creates a new circle physics body with generic parameters
PHYSACDEF PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); // Creates a new rectangle physics body with generic parameters
PHYSACDEF PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); // Creates a new polygon physics body with generic parameters
PHYSACDEF void DestroyPhysicsBody(PhysicsBody body); // Destroy a physics body
// Physic body forces
PHYSACDEF void PhysicsAddForce(PhysicsBody body, Vector2 force); // Adds a force to a physics body
PHYSACDEF void PhysicsAddTorque(PhysicsBody body, float amount); // Adds an angular force to a physics body
PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force); // Shatters a polygon shape physics body to little physics bodies with explosion force
PHYSACDEF void SetPhysicsBodyRotation(PhysicsBody body, float radians); // Sets physics body shape transform based on radians parameter
// Query physics info
PHYSACDEF PhysicsBody GetPhysicsBody(int index); // Returns a physics body of the bodies pool at a specific index
PHYSACDEF int GetPhysicsBodiesCount(void); // Returns the current amount of created physics bodies
PHYSACDEF int GetPhysicsShapeType(int index); // Returns the physics body shape type (PHYSICS_CIRCLE or PHYSICS_POLYGON)
PHYSACDEF int GetPhysicsShapeVerticesCount(int index); // Returns the amount of vertices of a physics body shape
PHYSACDEF Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex); // Returns transformed position of a body shape (body position + vertex transformed position)

244
raylib/raygui_modified.h Normal file
View file

@ -0,0 +1,244 @@
// Style property
typedef struct GuiStyleProp {
unsigned short controlId;
unsigned short propertyId;
int propertyValue;
} GuiStyleProp;
// Gui control state
typedef enum {
GUI_STATE_NORMAL = 0,
GUI_STATE_FOCUSED,
GUI_STATE_PRESSED,
GUI_STATE_DISABLED,
} GuiControlState;
// Gui control text alignment
typedef enum {
GUI_TEXT_ALIGN_LEFT = 0,
GUI_TEXT_ALIGN_CENTER,
GUI_TEXT_ALIGN_RIGHT,
} GuiTextAlignment;
// Gui controls
typedef enum {
DEFAULT = 0,
LABEL, // LABELBUTTON
BUTTON, // IMAGEBUTTON
TOGGLE, // TOGGLEGROUP
SLIDER, // SLIDERBAR
PROGRESSBAR,
CHECKBOX,
COMBOBOX,
DROPDOWNBOX,
TEXTBOX, // TEXTBOXMULTI
VALUEBOX,
SPINNER,
LISTVIEW,
COLORPICKER,
SCROLLBAR,
STATUSBAR
} GuiControl;
// Gui base properties for every control
typedef enum {
BORDER_COLOR_NORMAL = 0,
BASE_COLOR_NORMAL,
TEXT_COLOR_NORMAL,
BORDER_COLOR_FOCUSED,
BASE_COLOR_FOCUSED,
TEXT_COLOR_FOCUSED,
BORDER_COLOR_PRESSED,
BASE_COLOR_PRESSED,
TEXT_COLOR_PRESSED,
BORDER_COLOR_DISABLED,
BASE_COLOR_DISABLED,
TEXT_COLOR_DISABLED,
BORDER_WIDTH,
TEXT_PADDING,
TEXT_ALIGNMENT,
RESERVED
} GuiControlProperty;
// Gui extended properties depend on control
// NOTE: We reserve a fixed size of additional properties per control
// DEFAULT properties
typedef enum {
TEXT_SIZE = 16,
TEXT_SPACING,
LINE_COLOR,
BACKGROUND_COLOR,
} GuiDefaultProperty;
// Label
//typedef enum { } GuiLabelProperty;
// Button
//typedef enum { } GuiButtonProperty;
// Toggle / ToggleGroup
typedef enum {
GROUP_PADDING = 16,
} GuiToggleProperty;
// Slider / SliderBar
typedef enum {
SLIDER_WIDTH = 16,
SLIDER_PADDING
} GuiSliderProperty;
// ProgressBar
typedef enum {
PROGRESS_PADDING = 16,
} GuiProgressBarProperty;
// CheckBox
typedef enum {
CHECK_PADDING = 16
} GuiCheckBoxProperty;
// ComboBox
typedef enum {
COMBO_BUTTON_WIDTH = 16,
COMBO_BUTTON_PADDING
} GuiComboBoxProperty;
// DropdownBox
typedef enum {
ARROW_PADDING = 16,
DROPDOWN_ITEMS_PADDING
} GuiDropdownBoxProperty;
// TextBox / TextBoxMulti / ValueBox / Spinner
typedef enum {
TEXT_INNER_PADDING = 16,
TEXT_LINES_PADDING,
COLOR_SELECTED_FG,
COLOR_SELECTED_BG
} GuiTextBoxProperty;
// Spinner
typedef enum {
SPIN_BUTTON_WIDTH = 16,
SPIN_BUTTON_PADDING,
} GuiSpinnerProperty;
// ScrollBar
typedef enum {
ARROWS_SIZE = 16,
ARROWS_VISIBLE,
SCROLL_SLIDER_PADDING,
SCROLL_SLIDER_SIZE,
SCROLL_PADDING,
SCROLL_SPEED,
} GuiScrollBarProperty;
// ScrollBar side
typedef enum {
SCROLLBAR_LEFT_SIDE = 0,
SCROLLBAR_RIGHT_SIDE
} GuiScrollBarSide;
// ListView
typedef enum {
LIST_ITEMS_HEIGHT = 16,
LIST_ITEMS_PADDING,
SCROLLBAR_WIDTH,
SCROLLBAR_SIDE,
} GuiListViewProperty;
// ColorPicker
typedef enum {
COLOR_SELECTOR_SIZE = 16,
HUEBAR_WIDTH, // Right hue bar width
HUEBAR_PADDING, // Right hue bar separation from panel
HUEBAR_SELECTOR_HEIGHT, // Right hue bar selector height
HUEBAR_SELECTOR_OVERFLOW // Right hue bar selector overflow
} GuiColorPickerProperty;
// Global gui state control functions
RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state)
RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state)
RAYGUIDEF void GuiLock(void); // Lock gui controls (global state)
RAYGUIDEF void GuiUnlock(void); // Unlock gui controls (global state)
RAYGUIDEF void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
RAYGUIDEF void GuiSetState(int state); // Set gui state (global state)
RAYGUIDEF int GuiGetState(void); // Get gui state (global state)
// Font set/get functions
RAYGUIDEF void GuiSetFont(Font font); // Set gui custom font (global state)
RAYGUIDEF Font GuiGetFont(void); // Get gui custom font (global state)
// Style set/get functions
RAYGUIDEF void GuiSetStyle(int control, int property, int value); // Set one style property
RAYGUIDEF int GuiGetStyle(int control, int property); // Get one style property
// Container/separator controls, useful for controls organization
RAYGUIDEF bool GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed
RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name
RAYGUIDEF void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text
RAYGUIDEF void GuiPanel(Rectangle bounds); // Panel control, useful to group controls
RAYGUIDEF Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll); // Scroll Panel control
// Basic controls set
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
RAYGUIDEF bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture); // Image button control, returns true when clicked
RAYGUIDEF bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource); // Image button extended control, returns true when clicked
RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool active); // Toggle Button control, returns true when active
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char *text, int active); // Toggle Group control, returns active toggle index
RAYGUIDEF bool GuiCheckBox(Rectangle bounds, const char *text, bool checked); // Check Box control, returns true when active
RAYGUIDEF int GuiComboBox(Rectangle bounds, const char *text, int active); // Combo Box control, returns selected item index
RAYGUIDEF bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item
RAYGUIDEF bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
RAYGUIDEF bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
RAYGUIDEF bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text
RAYGUIDEF bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control with multiple lines
RAYGUIDEF float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider control, returns selected value
RAYGUIDEF float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
RAYGUIDEF float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value
RAYGUIDEF void GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text
RAYGUIDEF void GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders
RAYGUIDEF int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll Bar control
RAYGUIDEF Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs); // Grid control
// Advance controls set
RAYGUIDEF int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
RAYGUIDEF int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
RAYGUIDEF int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
RAYGUIDEF int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text
RAYGUIDEF Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control (multiple color controls)
RAYGUIDEF Color GuiColorPanel(Rectangle bounds, Color color); // Color Panel control
RAYGUIDEF float GuiColorBarAlpha(Rectangle bounds, float alpha); // Color Bar Alpha control
RAYGUIDEF float GuiColorBarHue(Rectangle bounds, float value); // Color Bar Hue control
// Styles loading functions
RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.rgs)
RAYGUIDEF void GuiLoadStyleDefault(void); // Load style default over global style
/*
typedef GuiStyle (unsigned int *)
RAYGUIDEF GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs)
RAYGUIDEF void UnloadGuiStyle(GuiStyle style); // Unload style
*/
RAYGUIDEF const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported)
// Gui icons functionality
RAYGUIDEF void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color);
RAYGUIDEF unsigned int *GuiGetIcons(void); // Get full icons data pointer
RAYGUIDEF unsigned int *GuiGetIconData(int iconId); // Get icon bit data
RAYGUIDEF void GuiSetIconData(int iconId, unsigned int *data); // Set icon bit data
RAYGUIDEF void GuiSetIconPixel(int iconId, int x, int y); // Set icon pixel value
RAYGUIDEF void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pixel value
RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value

File diff suppressed because it is too large Load diff

70
test_physac.py Normal file
View 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_LEFT_BUTTON):
body = CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10)
elif IsMouseButtonPressed(MOUSE_RIGHT_BUTTON):
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
test_physac2.py Normal file
View 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()

View file

@ -23,8 +23,8 @@ pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
print(str(rayhit.position.x))
#rayhit = pr.get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
while not pr.window_should_close():
pr.update_camera(camera)
@ -39,7 +39,7 @@ while not pr.window_should_close():
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
#rayhit = pr.get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
pr.close_window()

View file

@ -23,8 +23,8 @@ set_camera_mode(camera, CAMERA_ORBITAL)
pos = get_mouse_position()
ray = get_mouse_ray(pos, camera)
rayhit = get_collision_ray_ground(ray, 0)
print(str(rayhit.position.x))
#rayhit = get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
while not window_should_close():
update_camera(camera)
@ -39,7 +39,7 @@ while not window_should_close():
pos = get_mouse_position()
ray = get_mouse_ray(pos, camera)
rayhit = get_collision_ray_ground(ray, 0)
#rayhit = get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
close_window()

View file

@ -25,8 +25,8 @@ pr.set_camera_mode(camera, pr.CAMERA_ORBITAL)
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
print(str(rayhit.position.x))
#rayhit = pr.get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
while not pr.window_should_close():
pr.update_camera(camera)
@ -41,7 +41,7 @@ while not pr.window_should_close():
pos = pr.get_mouse_position()
ray = pr.get_mouse_ray(pos, camera)
rayhit = pr.get_collision_ray_ground(ray, 0)
#rayhit = pr.get_ray_collision_ground(ray, 0)
#print(str(rayhit.position.x))
pr.close_window()

View file

@ -1 +1 @@
__version__ = "3.7.0.post9"
__version__ = "4.0a1"