diff options
| author | victorfisac <victorfisac@gmail.com> | 2016-03-23 15:50:41 +0100 |
|---|---|---|
| committer | victorfisac <victorfisac@gmail.com> | 2016-03-23 15:50:41 +0100 |
| commit | 60223a358b691c2769c362597c49e124b045209c (patch) | |
| tree | 2850c0cbd1ec53e25cf70fd951518efd636b2066 /examples/physics_basic_rigidbody.c | |
| parent | c453ac8265525fd7a88ed616c7e5bdf1e6d6b09f (diff) | |
| download | raylib-60223a358b691c2769c362597c49e124b045209c.tar.gz raylib-60223a358b691c2769c362597c49e124b045209c.zip | |
Physac redesign (3/3)
Finally, physics update is handled in main thread using steps to get
accuracy in collisions detection instead of moving it to a new thread.
Examples are finished as simple and clear as I could. Finally, physac
module is MORE simpler than in the first version, calculation everything
by the same way for both types of physic objects.
I tryed to add rotated physics a couple of times but I didn't get
anything good to get a base to improve it. Maybe for the next version...
No bugs or strange behaviours found during testing.
Diffstat (limited to 'examples/physics_basic_rigidbody.c')
| -rw-r--r-- | examples/physics_basic_rigidbody.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/physics_basic_rigidbody.c b/examples/physics_basic_rigidbody.c index f0edba72..917813ad 100644 --- a/examples/physics_basic_rigidbody.c +++ b/examples/physics_basic_rigidbody.c @@ -65,7 +65,7 @@ int main() if (IsKeyDown('A')) rectangle->rigidbody.velocity.x = -MOVE_VELOCITY; else if (IsKeyDown('D')) rectangle->rigidbody.velocity.x = MOVE_VELOCITY; - // Check player 2 movement inputs + // Check square movement inputs if (IsKeyDown(KEY_UP) && square->rigidbody.isGrounded) square->rigidbody.velocity.y = JUMP_VELOCITY; if (IsKeyDown(KEY_LEFT)) square->rigidbody.velocity.x = -MOVE_VELOCITY; else if (IsKeyDown(KEY_RIGHT)) square->rigidbody.velocity.x = MOVE_VELOCITY; @@ -80,17 +80,20 @@ int main() ClearBackground(RAYWHITE); - // Convert transform values to rectangle data type variable - DrawRectangleRec(TransformToRectangle(floor->transform), DARKGRAY); + // Draw floor, roof and walls rectangles + DrawRectangleRec(TransformToRectangle(floor->transform), DARKGRAY); // Convert transform values to rectangle data type variable DrawRectangleRec(TransformToRectangle(leftWall->transform), DARKGRAY); DrawRectangleRec(TransformToRectangle(rightWall->transform), DARKGRAY); DrawRectangleRec(TransformToRectangle(roof->transform), DARKGRAY); + // Draw middle platform rectangle DrawRectangleRec(TransformToRectangle(platform->transform), DARKGRAY); + // Draw physic objects DrawRectangleRec(TransformToRectangle(rectangle->transform), RED); DrawRectangleRec(TransformToRectangle(square->transform), BLUE); + // Draw collider lines if debug is enabled if (isDebug) { DrawRectangleLines(floor->collider.bounds.x, floor->collider.bounds.y, floor->collider.bounds.width, floor->collider.bounds.height, GREEN); |
