Skip to content

Commit

Permalink
Reduce clipping through boosters
Browse files Browse the repository at this point in the history
Remove 1 tile gap on level 10
Lower the goal on level 11
  • Loading branch information
nfaltermeier committed May 7, 2021
1 parent 80b3f0f commit 323266c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Actors/Booster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ private bool Body_OnCollision(Fixture sender, Fixture other, Contact contact)
{
if (tag == ColliderTags.Player && !Player.IsBoostingDirections.Contains(boosterType))
{
Vector2 normVel = other.Body.LinearVelocity;
normVel.Normalize();
// Helps prevent clipping through a booster by moving too fast the opposite direction
if (Vector2.Dot(direction, normVel) < -0.4f)
{
other.Body.LinearVelocity = other.Body.LinearVelocity / 2;
}
other.Body.ApplyForce(direction * 500 * other.Body.Mass * MainGame.PhysicsScale);
Player.IsBoostingDirections.Add(boosterType);
}
Expand Down
2 changes: 1 addition & 1 deletion Content/Levels/10.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
1,0,0,12,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,4,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1,
1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,
1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
</data>
Expand Down
4 changes: 2 additions & 2 deletions Content/Levels/11.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<data encoding="csv">
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,9,0,0,0,0,0,1,
1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,1,
1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,1,
1,12,0,0,0,0,12,0,0,0,0,12,0,0,0,0,12,12,0,9,0,0,0,9,0,0,0,0,0,1,
1,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,1,1,1,1,1,1,1,0,0,0,1,
Expand Down

0 comments on commit 323266c

Please sign in to comment.