Skip to content

Commit

Permalink
Merge pull request #41 from uku1928/main
Browse files Browse the repository at this point in the history
Anvil: fixed EVERYTHING
  • Loading branch information
IonutParau authored Aug 19, 2023
2 parents eb33b16 + 5cc8980 commit ed42fdf
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lib/logic/update/anvil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,30 @@ void anvil() {
final double lossUponLethalImpact = cell.data["impact_loss"].toDouble();
final double terminalVelocity = cell.data["speed_limit"].toDouble();

cell.data["velocity"] += gravity;
velocity += gravity;
if(velocity > terminalVelocity) {
velocity = terminalVelocity;
cell.data["velocity"] = terminalVelocity;
}

if(doSpeedMover(x, y, dir, velocity.toInt(), velocity.toInt())) {
if(velocity >= breakingVelocity) {
final dx = frontX(x, dir);
final dy = frontY(y, dir);
if(grid.inside(dx, dy) && breakable(grid.at(dx, dy), dx, dy, dir, BreakType.gravity)) {
grid.set(dx, dy, Cell(dx, dy));
final int intVelocity = velocity.toInt();

for (var i = 0; i < intVelocity; i++) {
if (!push(x, y, dir, intVelocity)) {
if(velocity >= breakingVelocity) {
final dx = frontX(x, dir);
final dy = frontY(y, dir);
if(grid.inside(dx, dy) && breakable(grid.at(dx, dy), dx, dy, dir, BreakType.gravity)) {
grid.addBroken(grid.at(dx, dy), dx, dy);
grid.set(dx, dy, Cell(dx, dy));
cell.data["velocity"] = velocity * (1 - lossUponLethalImpact);
return;
}
}
cell.data["velocity"] = 0;
return;
}
cell.data["velocity"] = velocity * (1 - lossUponLethalImpact / 100);
x = frontX(x, dir);
y = frontY(y, dir);
}
cell.data["velocity"] = velocity;
}, null, "anvil");
}
}

0 comments on commit ed42fdf

Please sign in to comment.