From c3df65d8d09df9cf1c0bc1737a7e8ebbb0ead623 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 25 Feb 2009 15:48:50 +0100 Subject: [PATCH] Physics: Added a method to Body that resets the applied forces. --- src/net/habraun/kong/physics/Body.scala | 4 ++++ test/net/habraun/kong/physics/BodyTest.scala | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/net/habraun/kong/physics/Body.scala b/src/net/habraun/kong/physics/Body.scala index e8e3b1f..ffb88f3 100644 --- a/src/net/habraun/kong/physics/Body.scala +++ b/src/net/habraun/kong/physics/Body.scala @@ -124,6 +124,10 @@ class Body { _appliedForce = _appliedForce + f } + def resetForce { + _appliedForce = Vec2D(0, 0) + } + /** diff --git a/test/net/habraun/kong/physics/BodyTest.scala b/test/net/habraun/kong/physics/BodyTest.scala index bb6f110..511ccc9 100644 --- a/test/net/habraun/kong/physics/BodyTest.scala +++ b/test/net/habraun/kong/physics/BodyTest.scala @@ -170,6 +170,16 @@ class BodyTest { + @Test + def applyForceResetForce { + val body = new Body + body.applyForce(Vec2D(10, 10)) + body.resetForce + assertEquals(Vec2D(0, 0), body.appliedForce) + } + + + @Test { val expected = classOf[NullPointerException] } def applyNullForceExpectException { val body = new Body -- 2.11.4.GIT