2
* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
4
* This software is provided 'as-is', without any express or implied
5
* warranty. In no event will the authors be held liable for any damages
6
* arising from the use of this software.
7
* Permission is granted to anyone to use this software for any purpose,
8
* including commercial applications, and to alter it and redistribute it
9
* freely, subject to the following restrictions:
10
* 1. The origin of this software must not be misrepresented; you must not
11
* claim that you wrote the original software. If you use this software
12
* in a product, an acknowledgment in the product documentation would be
13
* appreciated but is not required.
14
* 2. Altered source versions must be plainly marked as such, and must not be
15
* misrepresented as being the original software.
16
* 3. This notice may not be removed or altered from any source distribution.
22
class Dominos : public Test
31
shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
34
b1 = m_world->CreateBody(&bd);
35
b1->CreateFixture(&shape, 0.0f);
40
shape.SetAsBox(6.0f, 0.25f);
43
bd.position.Set(-1.5f, 10.0f);
44
b2Body* ground = m_world->CreateBody(&bd);
45
ground->CreateFixture(&shape, 0.0f);
50
shape.SetAsBox(0.1f, 1.0f);
57
for (int i = 0; i < 10; ++i)
60
bd.type = b2_dynamicBody;
61
bd.position.Set(-6.0f + 1.0f * i, 11.25f);
62
b2Body* body = m_world->CreateBody(&bd);
63
body->CreateFixture(&fd);
69
shape.SetAsBox(7.0f, 0.25f, b2Vec2_zero, 0.3f);
72
bd.position.Set(1.0f, 6.0f);
73
b2Body* ground = m_world->CreateBody(&bd);
74
ground->CreateFixture(&shape, 0.0f);
80
shape.SetAsBox(0.25f, 1.5f);
83
bd.position.Set(-7.0f, 4.0f);
84
b2 = m_world->CreateBody(&bd);
85
b2->CreateFixture(&shape, 0.0f);
91
shape.SetAsBox(6.0f, 0.125f);
94
bd.type = b2_dynamicBody;
95
bd.position.Set(-0.9f, 1.0f);
98
b3 = m_world->CreateBody(&bd);
99
b3->CreateFixture(&shape, 10.0f);
102
b2RevoluteJointDef jd;
105
anchor.Set(-2.0f, 1.0f);
106
jd.Initialize(b1, b3, anchor);
107
jd.collideConnected = true;
108
m_world->CreateJoint(&jd);
112
b2PolygonShape shape;
113
shape.SetAsBox(0.25f, 0.25f);
116
bd.type = b2_dynamicBody;
117
bd.position.Set(-10.0f, 15.0f);
118
b4 = m_world->CreateBody(&bd);
119
b4->CreateFixture(&shape, 10.0f);
122
anchor.Set(-7.0f, 15.0f);
123
jd.Initialize(b2, b4, anchor);
124
m_world->CreateJoint(&jd);
129
bd.type = b2_dynamicBody;
130
bd.position.Set(6.5f, 3.0f);
131
b5 = m_world->CreateBody(&bd);
133
b2PolygonShape shape;
140
shape.SetAsBox(1.0f, 0.1f, b2Vec2(0.0f, -0.9f), 0.0f);
141
b5->CreateFixture(&fd);
143
shape.SetAsBox(0.1f, 1.0f, b2Vec2(-0.9f, 0.0f), 0.0f);
144
b5->CreateFixture(&fd);
146
shape.SetAsBox(0.1f, 1.0f, b2Vec2(0.9f, 0.0f), 0.0f);
147
b5->CreateFixture(&fd);
150
anchor.Set(6.0f, 2.0f);
151
jd.Initialize(b1, b5, anchor);
152
m_world->CreateJoint(&jd);
156
b2PolygonShape shape;
157
shape.SetAsBox(1.0f, 0.1f);
160
bd.type = b2_dynamicBody;
161
bd.position.Set(6.5f, 4.1f);
162
b6 = m_world->CreateBody(&bd);
163
b6->CreateFixture(&shape, 30.0f);
166
anchor.Set(7.5f, 4.0f);
167
jd.Initialize(b5, b6, anchor);
168
m_world->CreateJoint(&jd);
172
b2PolygonShape shape;
173
shape.SetAsBox(0.1f, 1.0f);
176
bd.type = b2_dynamicBody;
177
bd.position.Set(7.4f, 1.0f);
179
b7 = m_world->CreateBody(&bd);
180
b7->CreateFixture(&shape, 10.0f);
183
b2DistanceJointDef djd;
186
djd.localAnchorA.Set(6.0f, 0.0f);
187
djd.localAnchorB.Set(0.0f, -1.0f);
188
b2Vec2 d = djd.bodyB->GetWorldPoint(djd.localAnchorB) - djd.bodyA->GetWorldPoint(djd.localAnchorA);
189
djd.length = d.Length();
190
m_world->CreateJoint(&djd);
193
float32 radius = 0.2f;
196
shape.m_radius = radius;
198
for (int32 i = 0; i < 4; ++i)
201
bd.type = b2_dynamicBody;
202
bd.position.Set(5.9f + 2.0f * radius * i, 2.4f);
203
b2Body* body = m_world->CreateBody(&bd);
204
body->CreateFixture(&shape, 10.0f);
209
static Test* Create()