Skip to content

Commit

Permalink
Code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mystic-Slice committed Mar 4, 2022
1 parent e2900e3 commit 58cbfde
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
public class RubbleCreationSystem implements EventReceiver {

public static final float SIZE_TO_RUBBLE_COUNT = 8f;
public static final float MIN_DIVISIBLE_SIZE = .1f;
public static final float MIN_SCALE = .1f;
public static final float MAX_SCALE = .3f;
private static final float MAX_SPD = 40f;
Expand Down Expand Up @@ -116,7 +117,8 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
element.graphicsOffset = new Vector2();

float scale = SolRandom.randomFloat(MIN_SCALE, MAX_SCALE);
element.setSize(scale * size.size);
float scaledSize = scale * size.size;
element.setSize(scaledSize);

element.relativePosition = new Vector2();
element.tint = Color.WHITE;
Expand All @@ -126,7 +128,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
//Create position component
float velocityAngle = SolRandom.randomFloat(180);
Vector2 position = new Vector2();
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(size.size));
SolMath.fromAl(position, velocityAngle, SolRandom.randomFloat(scaledSize));
position.add(basePos);
Position positionComponent = new Position();
positionComponent.position = position;
Expand All @@ -137,7 +139,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz

//Create size component
Size sizeComponent = new Size();
sizeComponent.size = scale * size.size;
sizeComponent.size = scaledSize;

//Create velocity component
Velocity velocityComponent = new Velocity();
Expand All @@ -148,7 +150,7 @@ private void buildRubblePieces(Position pos, Velocity vel, Angle angle, Size siz
EntityRef entityRef = entitySystemManager.getEntityManager().createEntity(graphicsComponent, positionComponent,
sizeComponent, angle, velocityComponent, new RubbleMesh(), health);

if (sizeComponent.size > 0.1) {
if (scaledSize > MIN_DIVISIBLE_SIZE) {
entityRef.setComponent(new CreatesRubbleOnDestruction());
entityRef.setComponent(new DropsMoneyOnDestruction());
}
Expand Down

0 comments on commit 58cbfde

Please sign in to comment.