aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2016-06-14 21:38:09 +0200
committerGitHub <noreply@github.com>2016-06-14 21:38:09 +0200
commitd5d1305bc06f24b21e70b7ed0f8bc0b774e55727 (patch)
tree476364c8de14d560d975d7a6e8e4a427fe96ed35 /examples
parentd1a5374ac42e054ca65793f7358fc21bbcf393b9 (diff)
parent1b0996fb0bcf68e2a14bc6260c6f2c5366ab033f (diff)
downloadraylib-d5d1305bc06f24b21e70b7ed0f8bc0b774e55727.tar.gz
raylib-d5d1305bc06f24b21e70b7ed0f8bc0b774e55727.zip
Merge pull request #131 from victorfisac/develop
Physac 1.0 module completed
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
//--------------------------------------------------------------------------------------