From 1638c71a000a1313cbfa5afd03582ec1d0aace2f Mon Sep 17 00:00:00 2001 From: Julian Date: Wed, 31 Jan 2024 20:51:08 +0100 Subject: [PATCH] Added isWithin Function to Vector2 --- src/main/java/pacmanGame/Vector2.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/pacmanGame/Vector2.java b/src/main/java/pacmanGame/Vector2.java index d2e95ef..e9da7c8 100644 --- a/src/main/java/pacmanGame/Vector2.java +++ b/src/main/java/pacmanGame/Vector2.java @@ -29,6 +29,14 @@ public class Vector2 { ); } + public boolean isWithin(Vector2 area) { + return this.x < area.x && + this.y < area.y && + this.x >= 0 && + this.y >= 0 + ; + } + public Vector2 Clone() { return new Vector2(this.x, this.y); }