mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Better physics
This commit is contained in:
parent
273f4590df
commit
3b340f7164
@ -13,7 +13,7 @@ public class PhysicsProcess implements AsyncProcess{
|
||||
private Array<PhysicRef> refs = new Array<>(false);
|
||||
private BodyDef def;
|
||||
|
||||
private EntityGroup<? extends Hitboxc> group;
|
||||
private EntityGroup<Unitc> group;
|
||||
private Filter flying = new Filter(){{
|
||||
maskBits = categoryBits = 2;
|
||||
}}, ground = new Filter(){{
|
||||
@ -44,17 +44,17 @@ public class PhysicsProcess implements AsyncProcess{
|
||||
});
|
||||
|
||||
//find entities without bodies and assign them
|
||||
for(Hitboxc entity : group){
|
||||
boolean grounded = ((Flyingc)entity).isGrounded();
|
||||
for(Unitc entity : group){
|
||||
boolean grounded = entity.isGrounded();
|
||||
|
||||
if(entity.body() == null){
|
||||
//add bodies to entities that have none
|
||||
CircleShape shape = new CircleShape();
|
||||
shape.setRadius(entity.hitSize() * 0.46f);
|
||||
shape.setRadius(entity.hitSize() / 2f);
|
||||
|
||||
FixtureDef fd = new FixtureDef();
|
||||
fd.shape = shape;
|
||||
fd.density = 10.0f;
|
||||
fd.density = 5.0f * entity.mass();
|
||||
fd.restitution = 0.05f;
|
||||
fd.filter.maskBits = fd.filter.categoryBits = (grounded ? ground : flying).maskBits;
|
||||
|
||||
@ -62,7 +62,6 @@ public class PhysicsProcess implements AsyncProcess{
|
||||
|
||||
Body body = physics.createBody(def);
|
||||
body.createFixture(fd);
|
||||
|
||||
body.setUserData(entity);
|
||||
|
||||
PhysicRef ref = new PhysicRef(entity, body);
|
||||
@ -101,7 +100,7 @@ public class PhysicsProcess implements AsyncProcess{
|
||||
ref.body.setLinearVelocity(ref.velocity);
|
||||
}
|
||||
|
||||
physics.step(Core.graphics.getDeltaTime(), 3, 3);
|
||||
physics.step(Core.graphics.getDeltaTime(), 8, 8);
|
||||
|
||||
//get delta vectors
|
||||
for(PhysicRef ref : refs){
|
||||
|
@ -89,11 +89,12 @@ public class UnitTypes implements ContentList{
|
||||
speed = 1f;
|
||||
accel = 0.08f;
|
||||
drag = 0f;
|
||||
mass = 2f;
|
||||
mass = 30f;
|
||||
flying = true;
|
||||
health = 75000;
|
||||
engineOffset = 40;
|
||||
engineSize = 7.3f;
|
||||
hitsize = 58f;
|
||||
|
||||
weapons.add(new Weapon(){{
|
||||
y = 1.5f;
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=3533846d0009cda47c9416c4cb105b8e79518099
|
||||
archash=9fc6cd8c90e0665cc3a583879b2007fe29fbc929
|
||||
|
Loading…
Reference in New Issue
Block a user