is x,y inside a box defined by x,y1 and x,y2

i am instantiating a grid and i need to know if the current x,y is inside a box designated by xy1 and xy2

I’ve tried to find a way using >,< and && sings but conditions always end up negating each other , is there a better way to do this ?

so far but to no avail…

 for (int x = 0; x < gridsize; x++) {

	for (int y = 0; y < gridsize; y++) {
XY=new Vector2(x,y);
if ((x>20&&y>20)||(x<40&&y<40)){}}}

The simplest way of doing this is creating a rect object and using Rect.Contains().

 //example:
 var rect = new Rect( x , y , width , height);
 function HitTest(point : Vector2) {
       if (rect.Contains(point)) {
            print("The point is inside our rectangle");
       }
 }

Oh and by the way, in your original code, its only inside if all the conditions are true so you need and && instead of an ||.