• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 /*
17  * Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
20  * License. You may obtain a copy of the License at
21  *
22  * http://www.apache.org/licenses/LICENSE-2.0
23  *
24  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
25  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
26  * governing permissions and limitations under the License.
27  */
28 
29 package com.badlogic.gdx.tests.box2d;
30 
31 import com.badlogic.gdx.math.Vector2;
32 import com.badlogic.gdx.physics.box2d.Body;
33 import com.badlogic.gdx.physics.box2d.BodyDef;
34 import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
35 import com.badlogic.gdx.physics.box2d.CircleShape;
36 import com.badlogic.gdx.physics.box2d.EdgeShape;
37 import com.badlogic.gdx.physics.box2d.World;
38 
39 public class SphereStack extends Box2DTest {
40 	int e_count = 10;
41 
42 	@Override
createWorld(World world)43 	protected void createWorld (World world) {
44 		{
45 			BodyDef bd = new BodyDef();
46 			Body ground = world.createBody(bd);
47 
48 			EdgeShape shape = new EdgeShape();
49 			shape.set(new Vector2(-40, 0), new Vector2(40, 0));
50 			ground.createFixture(shape, 0);
51 			shape.dispose();
52 		}
53 
54 		{
55 			CircleShape shape = new CircleShape();
56 			shape.setRadius(1.0f);
57 
58 			for (int i = 0; i < e_count; i++) {
59 				BodyDef bd = new BodyDef();
60 				bd.type = BodyType.DynamicBody;
61 				bd.position.set(0, 4.0f + 3.0f * i);
62 				Body body = world.createBody(bd);
63 				body.createFixture(shape, 1.0f);
64 			}
65 
66 			shape.dispose();
67 		}
68 
69 	}
70 
71 }
72