Bullet mover cleanup

This commit is contained in:
Anuke
2022-03-05 22:52:20 -05:00
parent d92c9cfcf8
commit 7bf25cc46e
4 changed files with 19 additions and 11 deletions

View File

@@ -123,9 +123,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
@Override
public void update(){
if(mover != null){
float v = mover.move(self()) * Time.delta;
float ang = vel.angle();
vel.add(Angles.trnsx(ang, 0f, v), Angles.trnsy(ang, 0f, v)).limit(type.speed);
mover.move(self());
}
type.update(self());
@@ -140,6 +138,17 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
}
}
public void moveRelative(float x, float y){
float rot = rotation();
this.x += Angles.trnsx(rot, x * Time.delta, y * Time.delta);
this.y += Angles.trnsy(rot, x * Time.delta, y * Time.delta);
}
public void turn(float x, float y){
float ang = vel.angle();
vel.add(Angles.trnsx(ang, x * Time.delta, y * Time.delta), Angles.trnsy(ang, x * Time.delta, y * Time.delta)).limit(type.speed);
}
//copy-paste of World#raycastEach, inlined for lambda capture performance.
@Override
public void tileRaycast(int x1, int y1, int x2, int y2){