aboutsummaryrefslogtreecommitdiff
path: root/examples/physics_basic_rigidbody.c
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-06-12 22:07:36 +0200
committervictorfisac <victorfisac@gmail.com>2016-06-12 22:07:36 +0200
commit6a2bbae5216e66e5581d697998efe135ad826c50 (patch)
treecbde724380be439df3384f64742ed5ac17c2cb15 /examples/physics_basic_rigidbody.c
parent5625c11e9982838498722c33d832289f3e79fa6e (diff)
downloadraylib-6a2bbae5216e66e5581d697998efe135ad826c50.tar.gz
raylib-6a2bbae5216e66e5581d697998efe135ad826c50.zip
Updated physics examples with new module changes
Diffstat (limited to 'examples/physics_basic_rigidbody.c')
-rw-r--r--examples/physics_basic_rigidbody.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/examples/physics_basic_rigidbody.c b/examples/physics_basic_rigidbody.c
index 24570426..811ab982 100644
--- a/examples/physics_basic_rigidbody.c
+++ b/examples/physics_basic_rigidbody.c
@@ -13,12 +13,10 @@
#define PHYSAC_IMPLEMENTATION
#include "physac.h"
-#include <pthread.h>
#define MOVE_VELOCITY 5
#define JUMP_VELOCITY 30
-void* PhysicsThread(void *arg);
int main()
{
@@ -28,7 +26,6 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [physac] example - basic rigidbody");
-
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
// Debug variables
@@ -56,10 +53,6 @@ int main()
// Create pplatform physic object
PhysicBody platform = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.7f }, 0.0f, (Vector2){ screenWidth*0.25f, 20 });
- // Create physics thread
- pthread_t tid;
- pthread_create(&tid, NULL, &PhysicsThread, NULL);
-
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -122,33 +115,10 @@ int main()
}
// De-Initialization
- //--------------------------------------------------------------------------------------
- pthread_cancel(tid); // Destroy physics thread
-
+ //--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics (including all loaded objects)
-
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
-}
-
-void* PhysicsThread(void *arg)
-{
- // Initialize time variables
- double currentTime = GetTime();
- double previousTime = currentTime;
-
- // Physics update loop
- while (!WindowShouldClose())
- {
- currentTime = GetTime();
- double deltaTime = (double)(currentTime - previousTime);
- previousTime = currentTime;
-
- // Delta time value needs to be inverse multiplied by physics time step value (1/target fps)
- UpdatePhysics(deltaTime/PHYSICS_TIMESTEP);
- }
-
- return NULL;
} \ No newline at end of file