aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/physics_basic_rigidbody.c14
-rw-r--r--examples/physics_forces.c12
2 files changed, 16 insertions, 10 deletions
diff --git a/examples/physics_basic_rigidbody.c b/examples/physics_basic_rigidbody.c
index 8870c55b..75720c97 100644
--- a/examples/physics_basic_rigidbody.c
+++ b/examples/physics_basic_rigidbody.c
@@ -5,6 +5,10 @@
* This example has been created using raylib 1.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
+*
+* Compile example using:
+* cmd /c IF NOT EXIST pthreadGC2.dll copy C:\raylib\raylib\src\external\pthread\pthreadGC2.dll $(CURRENT_DIRECTORY) /Y
+*
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -25,7 +29,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
@@ -60,11 +63,9 @@ int main()
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
- //----------------------------------------------------------------------------------
- UpdatePhysics(); // Update all created physic objects
-
+ //----------------------------------------------------------------------------------
// Check rectangle movement inputs
- if (IsKeyDown('W') && rectangle->rigidbody.isGrounded) rectangle->rigidbody.velocity.y = JUMP_VELOCITY;
+ if (IsKeyPressed('W')) rectangle->rigidbody.velocity.y = JUMP_VELOCITY;
if (IsKeyDown('A')) rectangle->rigidbody.velocity.x = -MOVE_VELOCITY;
else if (IsKeyDown('D')) rectangle->rigidbody.velocity.x = MOVE_VELOCITY;
@@ -111,6 +112,8 @@ int main()
// Draw help message
DrawText("Use WASD to move rectangle and ARROWS to move square", screenWidth/2 - MeasureText("Use WASD to move rectangle and ARROWS to move square", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
+ DrawFPS(10, 10);
+
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -118,7 +121,6 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics (including all loaded objects)
-
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
diff --git a/examples/physics_forces.c b/examples/physics_forces.c
index 3e90a21d..efe8e240 100644
--- a/examples/physics_forces.c
+++ b/examples/physics_forces.c
@@ -5,6 +5,11 @@
* This example has been created using raylib 1.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
+* NOTE: This example requires raylib module [rlgl]
+*
+* Compile example using:
+* cmd /c IF NOT EXIST pthreadGC2.dll copy C:\raylib\raylib\src\external\pthread\pthreadGC2.dll $(CURRENT_DIRECTORY) /Y
+*
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@@ -27,7 +32,6 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [physac] example - forces");
-
InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
// Global variables
@@ -69,7 +73,6 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- UpdatePhysics(); // Update all created physic objects
// Update mouse position value
mousePosition = GetMousePosition();
@@ -166,7 +169,9 @@ int main()
// Draw help messages
DrawText("Use LEFT MOUSE BUTTON to apply a force", screenWidth/2 - MeasureText("Use LEFT MOUSE BUTTON to apply a force", 20)/2, screenHeight*0.075f, 20, LIGHTGRAY);
- DrawText("Use R to reset objects position", screenWidth/2 - MeasureText("Use R to reset objects position", 20)/2, screenHeight*0.875f, 20, GRAY);
+ DrawText("Use R to reset objects position", screenWidth/2 - MeasureText("Use R to reset objects position", 20)/2, screenHeight*0.875f, 20, GRAY);
+
+ DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
@@ -175,7 +180,6 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
ClosePhysics(); // Unitialize physics module
-
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------