Skip to content

Commit

Permalink
use Vector2.Clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
van800 committed Mar 2, 2023
1 parent 4585770 commit 0d02df4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions mono/dodge_the_creeps/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ public override void _Process(double delta)
}

Position += velocity * (float)delta;
Position = new Vector2(
x: Mathf.Clamp(Position.X, 0, ScreenSize.X),
y: Mathf.Clamp(Position.Y, 0, ScreenSize.Y)
);

Position = Position.Clamp(Position, ScreenSize);

if (velocity.X != 0)
{
animatedSprite.Animation = "right";
Expand Down

0 comments on commit 0d02df4

Please sign in to comment.