, viewed 319 times)
public class Bounds
public float x, y, width, height;
public Bounds( float x, float y, float width, float height)
this. x = x;
this. y = y;
this. width = width;
this. height = height;
public boolean contains( float x, float y)
if ( x >= this. x && x <= this. x+ width && y >= this. y && y <= this. y+ height)
public boolean intersects( Bounds b)
boolean xBetween, widthBetween, yBetween, heightBetween;
xBetween = widthBetween = yBetween = heightBetween = false;
if ( x >= b. x && x <= b. x+ b. width)
xBetween = true;
if ( x+ width >= b. x && x+ width <= b. x+ b. width)
widthBetween = true;
if ( y >= b. y && y <= b. y+ b. height)
yBetween = true;
if ( y+ height >= b. y && y+ height <= b. y+ b. height)
heightBetween = true;
if (( widthBetween || xBetween) && ( yBetween || heightBetween))
To highlight a line (yellow background), prefix it with '@@'
To indicate that a line should be removed (red background), prefix it with '-'
To indicate that a line should be added (green background), prefix it with '+'
To post multiple snippets, seperate them by '~~~~'
java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org