mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-06-30 19:03:42 -04:00
Initial example update
- Updating examples with new changes.
This commit is contained in:
@ -29,7 +29,7 @@ public partial class physics_demo
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo");
|
||||
|
||||
// Physac logo drawing position
|
||||
@ -75,15 +75,15 @@ public partial class physics_demo
|
||||
}
|
||||
|
||||
// Reset physics input
|
||||
if (IsKeyPressed('R'))
|
||||
if (IsKeyPressed(KeyboardKey.KEY_R))
|
||||
{
|
||||
ResetPhysics();
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
// Physics body creation inputs
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
|
||||
else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
|
||||
|
||||
// Destroy falling physics bodies
|
||||
int bodiesCount = GetPhysicsBodiesCount();
|
||||
|
@ -28,7 +28,7 @@ public partial class physics_friction
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction");
|
||||
|
||||
// Physac logo drawing position
|
||||
@ -73,7 +73,7 @@ public partial class physics_friction
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
|
||||
{
|
||||
// Reset dynamic physics bodies position, velocity and rotation
|
||||
bodyA.position = new Vector2( 35, screenHeight*0.6f );
|
||||
|
@ -30,7 +30,7 @@ public partial class physics_movement
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement");
|
||||
|
||||
// Physac logo drawing position
|
||||
@ -68,7 +68,7 @@ public partial class physics_movement
|
||||
//----------------------------------------------------------------------------------
|
||||
RunPhysicsStep();
|
||||
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
|
||||
{
|
||||
// Reset movement physics body position, velocity and rotation
|
||||
body.position = new Vector2( screenWidth/2, screenHeight/2 );
|
||||
@ -77,11 +77,11 @@ public partial class physics_movement
|
||||
}
|
||||
|
||||
// Horizontal movement input
|
||||
if (IsKeyDown(KEY_RIGHT)) body.velocity.x = VELOCITY;
|
||||
else if (IsKeyDown(KEY_LEFT)) body.velocity.x = -VELOCITY;
|
||||
if (IsKeyDown(KeyboardKey.KEY_RIGHT)) body.velocity.x = VELOCITY;
|
||||
else if (IsKeyDown(KeyboardKey.KEY_LEFT)) body.velocity.x = -VELOCITY;
|
||||
|
||||
// Vertical movement input checking if player physics body is grounded
|
||||
if (IsKeyDown(KEY_UP) && body.isGrounded) body.velocity.y = -VELOCITY*4;
|
||||
if (IsKeyDown(KeyboardKey.KEY_UP) && body.isGrounded) body.velocity.y = -VELOCITY*4;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@ -28,7 +28,7 @@ public partial class physics_restitution
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution");
|
||||
|
||||
// Physac logo drawing position
|
||||
@ -61,7 +61,7 @@ public partial class physics_restitution
|
||||
//----------------------------------------------------------------------------------
|
||||
RunPhysicsStep();
|
||||
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
|
||||
{
|
||||
// Reset circles physics bodies position and velocity
|
||||
circleA.position = new Vector2( screenWidth*0.25f, screenHeight/2 );
|
||||
|
@ -28,7 +28,7 @@ public partial class physics_shatter
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter");
|
||||
|
||||
// Physac logo drawing position
|
||||
@ -60,13 +60,13 @@ public partial class physics_shatter
|
||||
CreatePhysicsBodyPolygon(new Vector2( screenWidth/2, screenHeight/2 ), GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
|
||||
}
|
||||
|
||||
if (IsKeyPressed('R')) // Reset physics input
|
||||
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
|
||||
{
|
||||
ResetPhysics();
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input
|
||||
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) // Physics shatter input
|
||||
{
|
||||
// Note: some values need to be stored in variables due to asynchronous changes during main thread
|
||||
int count = GetPhysicsBodiesCount();
|
||||
|
Reference in New Issue
Block a user