This commit is contained in:
Anuken
2020-09-12 12:47:18 -04:00
parent 197b67f8c1
commit fa9611e28c
14 changed files with 64 additions and 45 deletions

View File

@@ -30,6 +30,30 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
collisions.moveCheck(this, cx, cy, !type.allowLegStep ? EntityCollisions::solid : EntityCollisions::legsSolid);
}
@Override
public void add(){
resetLegs();
}
public void resetLegs(){
float rot = baseRotation;
int count = type.legCount;
float legLength = type.legLength;
this.legs = new Leg[count];
float spacing = 360f / count;
for(int i = 0; i < legs.length; i++){
Leg l = new Leg();
l.joint.trns(i * spacing + rot, legLength/2f + type.legBaseOffset).add(x, y);
l.base.trns(i * spacing + rot, legLength + type.legBaseOffset).add(x, y);
legs[i] = l;
}
}
@Override
public void update(){
if(Mathf.dst(deltaX(), deltaY()) > 0.001f){
@@ -37,23 +61,11 @@ abstract class LegsComp implements Posc, Rotc, Hitboxc, Flyingc, Unitc{
}
float rot = baseRotation;
int count = type.legCount;
float legLength = type.legLength;
//set up initial leg positions
if(legs.length != type.legCount){
this.legs = new Leg[count];
float spacing = 360f / count;
for(int i = 0; i < legs.length; i++){
Leg l = new Leg();
l.joint.trns(i * spacing + rot, legLength/2f + type.legBaseOffset).add(x, y);
l.base.trns(i * spacing + rot, legLength + type.legBaseOffset).add(x, y);
legs[i] = l;
}
resetLegs();
}
float moveSpeed = type.legSpeed;