From 907e27ef4e7a4220142e9e7ccfe711ae86dd6a4e Mon Sep 17 00:00:00 2001 From: Pablo Marcos Oltra Date: Sun, 29 Jul 2018 13:09:30 +0200 Subject: Fix Physac examples to be run without creating new thread --- examples/physac/physics_demo.c | 6 +++++- examples/physac/physics_friction.c | 4 +++- examples/physac/physics_movement.c | 4 +++- examples/physac/physics_restitution.c | 4 +++- examples/physac/physics_shatter.c | 7 +++++-- 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/physac/physics_demo.c b/examples/physac/physics_demo.c index 273b9931..d417efec 100644 --- a/examples/physac/physics_demo.c +++ b/examples/physac/physics_demo.c @@ -17,6 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION +#define PHYSAC_NO_THREADS #include "physac.h" int main() @@ -54,6 +55,8 @@ int main() // Update //---------------------------------------------------------------------------------- // Delay initialization of variables due to physics reset async + RunPhysicsStep(); + if (needsReset) { floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); @@ -61,6 +64,8 @@ int main() circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); circle->enabled = false; + + needsReset = false; } // Reset physics input @@ -134,4 +139,3 @@ int main() return 0; } - diff --git a/examples/physac/physics_friction.c b/examples/physac/physics_friction.c index b4cc571d..99491eeb 100644 --- a/examples/physac/physics_friction.c +++ b/examples/physac/physics_friction.c @@ -17,6 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION +#define PHYSAC_NO_THREADS #include "physac.h" int main() @@ -71,6 +72,8 @@ int main() { // Update //---------------------------------------------------------------------------------- + RunPhysicsStep(); + if (IsKeyPressed('R')) // Reset physics input { // Reset dynamic physics bodies position, velocity and rotation @@ -141,4 +144,3 @@ int main() return 0; } - diff --git a/examples/physac/physics_movement.c b/examples/physac/physics_movement.c index 3ca69671..4c4f259f 100644 --- a/examples/physac/physics_movement.c +++ b/examples/physac/physics_movement.c @@ -17,6 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION +#define PHYSAC_NO_THREADS #include "physac.h" #define VELOCITY 0.5f @@ -64,6 +65,8 @@ int main() { // Update //---------------------------------------------------------------------------------- + RunPhysicsStep(); + if (IsKeyPressed('R')) // Reset physics input { // Reset movement physics body position, velocity and rotation @@ -127,4 +130,3 @@ int main() return 0; } - diff --git a/examples/physac/physics_restitution.c b/examples/physac/physics_restitution.c index 8e26c93f..d2ec49db 100644 --- a/examples/physac/physics_restitution.c +++ b/examples/physac/physics_restitution.c @@ -17,6 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION +#define PHYSAC_NO_THREADS #include "physac.h" int main() @@ -57,6 +58,8 @@ int main() { // Update //---------------------------------------------------------------------------------- + RunPhysicsStep(); + if (IsKeyPressed('R')) // Reset physics input { // Reset circles physics bodies position and velocity @@ -120,4 +123,3 @@ int main() return 0; } - diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index e34d6cec..17f9bfc2 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -17,7 +17,8 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "physac.h" +#define PHYSAC_NO_THREADS +#include "physac.h" int main() { @@ -48,12 +49,15 @@ int main() while (!WindowShouldClose()) // Detect window close button or ESC key { // Update + RunPhysicsStep(); + //---------------------------------------------------------------------------------- // Delay initialization of variables due to physics reset asynchronous if (needsReset) { // Create random polygon physics body to shatter CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + needsReset = false; } if (IsKeyPressed('R')) // Reset physics input @@ -118,4 +122,3 @@ int main() return 0; } - -- cgit v1.2.3