posl = new Vector2(rand.nextInt(FLUC) , y); posr = new Vector2(posl.x - right.getWidth() , y); boundsleft = new Rectangle(posl.x, posl.y, left.getWidth(),left.getHeight()); boundsright = new Rectangle(posr.x, posr.y, right.getWidth(), right.getHeight()); public boolean overlaps(Rectangle rb){ return rb.overlaps(boundsleft) || rb.overlaps(boundsright); } These are lines from the Block class. From the very logic of the game:
for (Block tube : tubes) { if(tube.overlaps(Player.getRect()){ dm.set(new OtherState(dm)); } Well and creation Rect in class Player
rect = new Rectangle(x, y, player.getWidth(),player.getHeight()); tubes here is an Array Block> .dm object - abbr. from display manager - a stack of screen states. set (dm) method - combining the pop (dm) and push () methods.