summaryrefslogtreecommitdiffhomepage
path: root/examples/physac/physics_demo.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2018-03-11 11:02:03 +0100
committerraysan5 <[email protected]>2018-03-11 11:02:03 +0100
commitb9573e583f02fcdc0b283bacff3cb2025aebfa3d (patch)
treeca486eed505ecaff54eeeb1df52483ab67ddd476 /examples/physac/physics_demo.c
parentd6c1159fce69c556fefebb945fd857b3c761bfab (diff)
parent8bc2813b0cbb016206708c41762a2fe3f01d5a13 (diff)
downloadraylib-b9573e583f02fcdc0b283bacff3cb2025aebfa3d.tar.gz
raylib-b9573e583f02fcdc0b283bacff3cb2025aebfa3d.zip
Merge branch 'master' of https://github.com/raysan5/raylib
Diffstat (limited to 'examples/physac/physics_demo.c')
-rw-r--r--examples/physac/physics_demo.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/physac/physics_demo.c b/examples/physac/physics_demo.c
index 1b54d51b..d66d2fbe 100644
--- a/examples/physac/physics_demo.c
+++ b/examples/physac/physics_demo.c
@@ -10,7 +10,7 @@
* gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
*
-* Copyright (c) 2017 Victor Fisac
+* Copyright (c) 2016-2018 Victor Fisac
*
********************************************************************************************/
@@ -32,6 +32,7 @@ int main()
// Physac logo drawing position
int logoX = screenWidth - MeasureText("Physac", 30) - 10;
int logoY = 15;
+ bool needsReset = false;
// Initialize physics and default physics bodies
InitPhysics();
@@ -52,10 +53,9 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyPressed('R')) // Reset physics input
+ // Delay initialization of variables due to physics reset async
+ if (needsReset)
{
- ResetPhysics();
-
floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false;
@@ -63,6 +63,13 @@ int main()
circle->enabled = false;
}
+ // Reset physics input
+ if (IsKeyPressed('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);