Android Open Source - hackfmi-ragdoll-physics Central Hurdle From Project Back to project page hackfmi-ragdoll-physics .
License The source code is released under:
GNU General Public License
If you think the Android project hackfmi-ragdoll-physics listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.midtownmadness.bubblecombat.physics;
/ * w w w . j a v a 2 s . c o m * /
import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.BodyType;
import org.jbox2d.dynamics.FixtureDef;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import com.midtownmadness.bubblecombat.game.GameObject;
public class CentralHurdle extends GameObject {
private static final float ANGULAR_VELOCITY = 7f;
private static final float BLADE_LENGTH = 20f;
private static final float BLADE_WIDTH = 5f;
private float centerY;
private float centerX;
private float angle;
private Bitmap bitmap;
private Rect bitmapBounds;
private Rect boundingBox;
public CentralHurdle(float centerX, float centerY, float angle, Bitmap bitmap) {
this.centerX = centerX;
this.centerY = centerY;
this.angle = angle;
this.bitmap = bitmap;
bitmapBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
boundingBox = new Rect(
(int ) (centerX - BLADE_WIDTH / 2),
(int ) (centerY - BLADE_LENGTH),
(int ) (centerX + BLADE_WIDTH / 2),
(int ) (centerY));
}
@Override
public void render(Canvas canvas) {
if (body != null) {
canvas.save();
canvas.translate(centerX, centerY);
canvas.rotate((float ) Math.toDegrees(body.getAngle()));
canvas.translate(-centerX, -centerY);
canvas.drawBitmap(bitmap, bitmapBounds, boundingBox, null);
canvas.restore();
}
}
@Override
public BodyDef buildBodyDef() {
BodyDef result = new BodyDef();
result.type = BodyType.KINEMATIC;
result.angularVelocity = ANGULAR_VELOCITY;
result.position = new Vec2(centerX, centerY);
result.angle = angle;
return result;
}
@Override
public FixtureDef buildFixtureDef() {
FixtureDef result = new FixtureDef();
PolygonShape shape = new PolygonShape();
shape.setAsBox(BLADE_WIDTH / 2, BLADE_LENGTH / 2, new Vec2(BLADE_WIDTH / 2, BLADE_LENGTH / 2), 0);
result.shape = shape;
return result;
}
}
Java Source Code List com.midtownmadness.bubblecombar.listeners.GameRoomListener.java com.midtownmadness.bubblecombar.model.GameModel.java com.midtownmadness.bubblecombar.model.GamesAdapter.java com.midtownmadness.bubblecombar.model.MockAdapter.java com.midtownmadness.bubblecombat.BaseActivity.java com.midtownmadness.bubblecombat.BluetoothGamesAdapter.java com.midtownmadness.bubblecombat.GameActivity.java com.midtownmadness.bubblecombat.GameView.java com.midtownmadness.bubblecombat.GlobalContext.java com.midtownmadness.bubblecombat.MenuActivity.java com.midtownmadness.bubblecombat.MockMultiplayerGame.java com.midtownmadness.bubblecombat.Settings.java com.midtownmadness.bubblecombat.game.DrawThread.java com.midtownmadness.bubblecombat.game.GameObject.java com.midtownmadness.bubblecombat.game.GameWallObject.java com.midtownmadness.bubblecombat.game.LevelObject.java com.midtownmadness.bubblecombat.game.PlayerObject.java com.midtownmadness.bubblecombat.multiplay.BaseStrategy.java com.midtownmadness.bubblecombat.multiplay.BluetoothConnectException.java com.midtownmadness.bubblecombat.multiplay.BluetoothMessage.java com.midtownmadness.bubblecombat.multiplay.Callback.java com.midtownmadness.bubblecombat.multiplay.ClientStrategy.java com.midtownmadness.bubblecombat.multiplay.HostStrategy.java com.midtownmadness.bubblecombat.multiplay.LoggingListener.java com.midtownmadness.bubblecombat.multiplay.LooperThread.java com.midtownmadness.bubblecombat.multiplay.MessageType.java com.midtownmadness.bubblecombat.multiplay.MultiplayEventListener.java com.midtownmadness.bubblecombat.multiplay.MultiplayEvent.java com.midtownmadness.bubblecombat.multiplay.MultiplayManager.java com.midtownmadness.bubblecombat.multiplay.MultiplayStrategy.java com.midtownmadness.bubblecombat.multiplay.MultiplayUtil.java com.midtownmadness.bubblecombat.multiplay.MultiplayerGame.java com.midtownmadness.bubblecombat.multiplay.commobjects.GoMessageObject.java com.midtownmadness.bubblecombat.physics.BodyCreationRequest.java com.midtownmadness.bubblecombat.physics.BodyUserData.java com.midtownmadness.bubblecombat.physics.CentralHurdle.java com.midtownmadness.bubblecombat.physics.CollisionListener.java com.midtownmadness.bubblecombat.physics.DefaultLevelBuilder.java com.midtownmadness.bubblecombat.physics.LevelBuilder.java com.midtownmadness.bubblecombat.physics.MovementRequest.java com.midtownmadness.bubblecombat.physics.MovementStateRequest.java com.midtownmadness.bubblecombat.physics.PhysicsRequest.java com.midtownmadness.bubblecombat.physics.PhysicsService.java com.midtownmadness.bubblecombat.views.MenuGameView.java com.midtownmadness.bubblecombat.views.MenuView.java