mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-11 19:37:47 +07:00
Changed player to circle shape
Changed player to circle shape Player will now face direction of linear velocity
This commit is contained in:
parent
1aae833301
commit
f79baf0c4c
@ -19,6 +19,7 @@ import com.badlogic.gdx.math.Vector3;
|
|||||||
import com.badlogic.gdx.physics.box2d.Body;
|
import com.badlogic.gdx.physics.box2d.Body;
|
||||||
import com.badlogic.gdx.physics.box2d.BodyDef;
|
import com.badlogic.gdx.physics.box2d.BodyDef;
|
||||||
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
|
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
|
||||||
|
import com.badlogic.gdx.physics.box2d.CircleShape;
|
||||||
import com.badlogic.gdx.physics.box2d.PolygonShape;
|
import com.badlogic.gdx.physics.box2d.PolygonShape;
|
||||||
import com.badlogic.gdx.physics.box2d.World;
|
import com.badlogic.gdx.physics.box2d.World;
|
||||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||||
@ -126,8 +127,8 @@ public class WallAggregatorTool extends ApplicationAdapter {
|
|||||||
playerDef.fixedRotation = true;
|
playerDef.fixedRotation = true;
|
||||||
playerDef.position.set(camera.position.x, camera.position.y);
|
playerDef.position.set(camera.position.x, camera.position.y);
|
||||||
|
|
||||||
PolygonShape playerShape = new PolygonShape();
|
CircleShape playerShape = new CircleShape();
|
||||||
playerShape.setAsBox(0.9f, 0.9f);
|
playerShape.setRadius(0.9f);
|
||||||
|
|
||||||
playerBody = world.createBody(playerDef);
|
playerBody = world.createBody(playerDef);
|
||||||
playerBody.createFixture(playerShape, 0);
|
playerBody.createFixture(playerShape, 0);
|
||||||
@ -192,10 +193,12 @@ public class WallAggregatorTool extends ApplicationAdapter {
|
|||||||
vec2b.set(Gdx.input.getX(), Gdx.input.getY());
|
vec2b.set(Gdx.input.getX(), Gdx.input.getY());
|
||||||
|
|
||||||
vec2b.sub(vec2a).nor();
|
vec2b.sub(vec2a).nor();
|
||||||
vec2a.nor().setAngleRad(Direction.snapToDirection(vec2b.angleRad(), 32));
|
float rad = Direction.snapToDirection(vec2b.angleRad(), 32);
|
||||||
|
vec2a.nor().setAngleRad(rad);
|
||||||
vec2a.scl(VELOCITY).rotate(-45);
|
vec2a.scl(VELOCITY).rotate(-45);
|
||||||
vec2a.y = -vec2a.y;
|
vec2a.y = -vec2a.y;
|
||||||
playerBody.setLinearVelocity(vec2a);
|
playerBody.setLinearVelocity(vec2a);
|
||||||
|
playerBody.setTransform(playerBody.getPosition(), vec2a.angleRad());
|
||||||
} else {
|
} else {
|
||||||
playerBody.setLinearVelocity(0, 0);
|
playerBody.setLinearVelocity(0, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user