aboutsummaryrefslogtreecommitdiff
path: root/examples/physics_basic_rigidbody.c
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-06-09 20:02:42 +0200
committerraysan5 <raysan5@gmail.com>2016-06-09 20:02:42 +0200
commit3c1be60c6615fdcf8d2e3ddec2c9d7de8174b280 (patch)
treed517180a95308e3dd8982795ecf9a52ec6e847b5 /examples/physics_basic_rigidbody.c
parent5f4449f0a199ae2f1750eb60f2fcc4dd8c41ab79 (diff)
downloadraylib-3c1be60c6615fdcf8d2e3ddec2c9d7de8174b280.tar.gz
raylib-3c1be60c6615fdcf8d2e3ddec2c9d7de8174b280.zip
Updated examples for new physac header-only
Diffstat (limited to 'examples/physics_basic_rigidbody.c')
-rw-r--r--examples/physics_basic_rigidbody.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/examples/physics_basic_rigidbody.c b/examples/physics_basic_rigidbody.c
index cd09f070..8870c55b 100644
--- a/examples/physics_basic_rigidbody.c
+++ b/examples/physics_basic_rigidbody.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
#define MOVE_VELOCITY 5
#define JUMP_VELOCITY 30
@@ -22,35 +25,35 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [physac] example - basic rigidbody");
- InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
- SetTargetFPS(60);
+ InitPhysics((Vector2){ 0.0f, -9.81f/2 }); // Initialize physics module
// Debug variables
bool isDebug = false;
// Create rectangle physic object
- PhysicObject rectangle = CreatePhysicObject((Vector2){ screenWidth*0.25f, screenHeight/2 }, 0.0f, (Vector2){ 75, 50 });
+ PhysicBody rectangle = CreatePhysicBody((Vector2){ screenWidth*0.25f, screenHeight/2 }, 0.0f, (Vector2){ 75, 50 });
rectangle->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
rectangle->rigidbody.applyGravity = true;
rectangle->rigidbody.friction = 0.1f;
rectangle->rigidbody.bounciness = 6.0f;
// Create square physic object
- PhysicObject square = CreatePhysicObject((Vector2){ screenWidth*0.75f, screenHeight/2 }, 0.0f, (Vector2){ 50, 50 });
+ PhysicBody square = CreatePhysicBody((Vector2){ screenWidth*0.75f, screenHeight/2 }, 0.0f, (Vector2){ 50, 50 });
square->rigidbody.enabled = true; // Enable physic object rigidbody behaviour
square->rigidbody.applyGravity = true;
square->rigidbody.friction = 0.1f;
// Create walls physic objects
- PhysicObject floor = CreatePhysicObject((Vector2){ screenWidth/2, screenHeight*0.95f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
- PhysicObject leftWall = CreatePhysicObject((Vector2){ 0.0f, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
- PhysicObject rightWall = CreatePhysicObject((Vector2){ screenWidth, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
- PhysicObject roof = CreatePhysicObject((Vector2){ screenWidth/2, screenHeight*0.05f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
+ PhysicBody floor = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.95f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
+ PhysicBody leftWall = CreatePhysicBody((Vector2){ 0.0f, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
+ PhysicBody rightWall = CreatePhysicBody((Vector2){ screenWidth, screenHeight/2 }, 0.0f, (Vector2){ screenWidth*0.1f, screenHeight });
+ PhysicBody roof = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.05f }, 0.0f, (Vector2){ screenWidth*0.9f, 100 });
// Create pplatform physic object
- PhysicObject platform = CreatePhysicObject((Vector2){ screenWidth/2, screenHeight*0.7f }, 0.0f, (Vector2){ screenWidth*0.25f, 20 });
+ PhysicBody platform = CreatePhysicBody((Vector2){ screenWidth/2, screenHeight*0.7f }, 0.0f, (Vector2){ screenWidth*0.25f, 20 });
+ SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop