Skip to content

Commit 92bfb3f

Browse files
author
Roger Zanoni
committed
Add box2ddistancejoints example
Signed-off-by: Roger Zanoni <roger.zanoni@openbossa.org>
1 parent 2711911 commit 92bfb3f

File tree

4 files changed

+298
-1
lines changed

4 files changed

+298
-1
lines changed
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
/**
2+
* Copyright (C) 2012 by INdT
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*
18+
* @author Rodrigo Goncalves de Oliveira <rodrigo.goncalves@openbossa.org>
19+
* @author Roger Felipe Zanoni da Silva <roger.zanoni@openbossa.org>
20+
*/
21+
22+
QuasiGame {
23+
id: game
24+
25+
width: 300
26+
height: 300
27+
28+
currentScene: scene
29+
30+
Rectangle {
31+
anchors.fill: parent
32+
color: "black"
33+
}
34+
35+
QuasiScene {
36+
id: scene
37+
38+
width: parent.width
39+
height: parent.height
40+
41+
QuasiEntity {
42+
id: static1
43+
44+
width: 30
45+
height: 30
46+
47+
y: 100
48+
x: 100
49+
50+
QuasiFixture {
51+
material: randomMaterial
52+
53+
anchors.fill: parent
54+
55+
shape: Rectangle {
56+
color: "white"
57+
anchors.fill: parent
58+
}
59+
}
60+
}
61+
62+
QuasiDistanceJoint {
63+
entityA: static1
64+
entityB: dynamic1
65+
66+
width: 1
67+
68+
Rectangle {
69+
anchors.fill: parent
70+
color: "green"
71+
radius: 5
72+
}
73+
}
74+
75+
QuasiEntity {
76+
id: dynamic1
77+
78+
property int centerX: x + (width / 2)
79+
property int centerY: y + (height / 2)
80+
81+
entityType: Quasi.DynamicType
82+
83+
width: 30
84+
height: 30
85+
86+
y: 200
87+
x: 100
88+
89+
QuasiFixture {
90+
material: randomMaterial
91+
92+
anchors.fill: parent
93+
94+
shape: QuasiCircle {
95+
anchors.fill: parent
96+
fill: QuasiColorFill {
97+
brushColor: "red"
98+
}
99+
}
100+
}
101+
}
102+
103+
QuasiEntity {
104+
id: static2
105+
106+
width: 30
107+
height: 30
108+
109+
y: 100
110+
x: 135
111+
112+
QuasiFixture {
113+
material: randomMaterial
114+
115+
anchors.fill: parent
116+
117+
shape: Rectangle {
118+
color: "white"
119+
anchors.fill: parent
120+
}
121+
}
122+
}
123+
124+
QuasiDistanceJoint {
125+
entityA: static2
126+
entityB: dynamic2
127+
128+
width: 1
129+
130+
Rectangle {
131+
anchors.fill: parent
132+
color: "green"
133+
radius: 5
134+
}
135+
}
136+
137+
QuasiEntity {
138+
id: dynamic2
139+
140+
entityType: Quasi.DynamicType
141+
142+
width: 30
143+
height: 30
144+
145+
y: 200
146+
x: 135
147+
148+
QuasiFixture {
149+
material: randomMaterial
150+
151+
anchors.fill: parent
152+
153+
shape: QuasiCircle {
154+
anchors.fill: parent
155+
fill: QuasiColorFill {
156+
brushColor: "red"
157+
}
158+
}
159+
}
160+
}
161+
162+
QuasiEntity {
163+
id: static3
164+
165+
width: 30
166+
height: 30
167+
168+
y: 100
169+
x: 170
170+
171+
QuasiFixture {
172+
material: randomMaterial
173+
174+
anchors.fill: parent
175+
176+
shape: Rectangle {
177+
color: "white"
178+
anchors.fill: parent
179+
}
180+
}
181+
}
182+
183+
QuasiDistanceJoint {
184+
entityA: static3
185+
entityB: dynamic3
186+
187+
width: 1
188+
189+
Rectangle {
190+
anchors.fill: parent
191+
color: "green"
192+
radius: 5
193+
}
194+
}
195+
196+
QuasiEntity {
197+
id: dynamic3
198+
199+
entityType: Quasi.DynamicType
200+
201+
width: 30
202+
height: 30
203+
204+
y: 200
205+
x: 170
206+
207+
QuasiFixture {
208+
material: randomMaterial
209+
210+
anchors.fill: parent
211+
212+
shape: QuasiCircle {
213+
anchors.fill: parent
214+
fill: QuasiColorFill {
215+
brushColor: "red"
216+
}
217+
}
218+
}
219+
}
220+
221+
QuasiEntity {
222+
id: static4
223+
224+
width: 30
225+
height: 30
226+
227+
y: 100
228+
x: 205
229+
230+
QuasiFixture {
231+
material: randomMaterial
232+
233+
anchors.fill: parent
234+
235+
shape: Rectangle {
236+
color: "white"
237+
anchors.fill: parent
238+
}
239+
}
240+
}
241+
242+
QuasiDistanceJoint {
243+
entityA: static4
244+
entityB: dynamic4
245+
246+
width: 1
247+
248+
Rectangle {
249+
anchors.fill: parent
250+
color: "green"
251+
radius: 5
252+
}
253+
}
254+
255+
QuasiEntity {
256+
id: dynamic4
257+
258+
entityType: Quasi.DynamicType
259+
260+
width: 30
261+
height: 30
262+
263+
y: 200
264+
x: 205
265+
266+
QuasiFixture {
267+
material: randomMaterial
268+
269+
anchors.fill: parent
270+
271+
shape: QuasiCircle {
272+
anchors.fill: parent
273+
fill: QuasiColorFill {
274+
brushColor: "red"
275+
}
276+
}
277+
}
278+
}
279+
280+
Component.onCompleted: dynamic1.applyLinearImpulse(Qt.point(-1000, 0), Qt.point(dynamic1.centerX, dynamic1.centerY))
281+
}
282+
283+
QuasiMaterial {
284+
id: randomMaterial
285+
286+
friction: 0.3 + Math.random() * 1.0
287+
density: 5 + Math.random() * 10
288+
restitution: 0.5 + Math.random() * 0.5
289+
}
290+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(../examples.pri)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!DOCTYPE RCC><RCC version="1.0">
2+
<qresource>
3+
<file>GameWindow.qml</file>
4+
</qresource>
5+
</RCC>

examples/examples.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ SUBDIRS += imagelayer \
1010
sprite \
1111
updateInterval \
1212
manysprites \
13-
behaviorchange
13+
behaviorchange \
14+
box2ddistancejoints

0 commit comments

Comments
 (0)