Back to project page SpaceRagdoll.
The source code is released under:
GNU General Public License
If you think the Android project SpaceRagdoll listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (C) 2015 Tuukka Ruhanen/* www .j a va 2s . co m*/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ package fi.karu.spaceragdoll; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.BodyDef; import com.badlogic.gdx.physics.box2d.CircleShape; import com.badlogic.gdx.physics.box2d.FixtureDef; import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; import com.badlogic.gdx.physics.box2d.World; public class Planet { public static final float M = 3000f; // gravity center mass public static final float R = 50f; private static final float FRICTION = .4f; private static final float RESTITUTION = .6f; private Body body; public Planet(Body b) { body = b; } public static Planet create(World world) { // planet body BodyDef bodyDef = new BodyDef(); bodyDef.position.set(new Vector2(0, -R)); Body body = world.createBody(bodyDef); CircleShape circle = new CircleShape(); circle.setRadius(R); FixtureDef fixtureDef = new FixtureDef(); fixtureDef.filter.groupIndex = -1; fixtureDef.shape = circle; fixtureDef.friction = FRICTION; fixtureDef.restitution = RESTITUTION; body.createFixture(fixtureDef); circle.dispose(); return new Planet(body); } public Body getBody() { return body; } }