Added run and walk speeds to VelocityComponent

Added run and walk speeds to VelocityComponent
Added RUNNING flag to tell if entity should use run or walk speed
This commit is contained in:
Collin Smith
2019-11-10 02:25:04 -08:00
parent 4ed6792996
commit 32b20d284e
2 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ public final class Flags {
public static final int SELECTABLE = 1 << 1;
public static final int SELECTED = 1 << 2;
public static final int INVISIBLE = 1 << 3;
public static final int RUNNING = 1 << 4;
public static String toString(int bits) {
StringBuilder builder = new StringBuilder();
@ -16,6 +17,7 @@ public final class Flags {
if ((bits & SELECTABLE) == SELECTABLE) builder.append("SELECTABLE").append("|");
if ((bits & SELECTED) == SELECTED) builder.append("SELECTED").append("|");
if ((bits & INVISIBLE) == INVISIBLE) builder.append("INVISIBLE").append("|");
if ((bits & RUNNING) == RUNNING) builder.append("RUNNING").append("|");
if (builder.length() > 0) builder.setLength(builder.length() - 1);
}
return builder.toString();

View File

@ -6,9 +6,13 @@ import com.badlogic.gdx.utils.Pool;
public class VelocityComponent implements Component, Pool.Poolable {
public final Vector2 velocity = new Vector2();
public float walkSpeed;
public float runSpeed;
@Override
public void reset() {
velocity.setZero();
walkSpeed = 0;
runSpeed = 0;
}
}