Skip to content

Commit 08b2353

Browse files
Added option to set the force at the center by typing 'c'
1 parent 94b6c7b commit 08b2353

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/tests/classes/tests/Box2DTestBet(Box2D)/Tests/ApplyForce.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,35 @@ public ApplyForce()
132132
}
133133
}
134134

135+
private bool _ApplyToCenter = false;
136+
135137
public override void Keyboard(char key)
136138
{
137139
switch (key)
138140
{
141+
case 'c':
142+
_ApplyToCenter = !_ApplyToCenter;
143+
break;
139144
case 'w':
140145
{
141146
b2Vec2 f = m_body.GetWorldVector(new b2Vec2(0.0f, -200.0f));
142147
b2Vec2 p = m_body.GetWorldPoint(new b2Vec2(0.0f, 2.0f));
143-
m_body.ApplyForce(f, p);
148+
if(_ApplyToCenter)
149+
m_body.ApplyForceToCenter(f);
150+
else
151+
m_body.ApplyForce(f, p);
152+
}
153+
break;
154+
case 'x':
155+
{
156+
b2Vec2 f = m_body.GetWorldVector(new b2Vec2(0.0f, 200.0f));
157+
b2Vec2 p = m_body.GetWorldPoint(new b2Vec2(0.0f, 2.0f));
158+
if (_ApplyToCenter)
159+
m_body.ApplyForceToCenter(f);
160+
else
161+
m_body.ApplyForce(f, p);
144162
}
145163
break;
146-
147164
case 'a':
148165
{
149166
m_body.ApplyTorque(50.0f);

0 commit comments

Comments
 (0)