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);
}
Это строки из класса Block. Из самой логики игры :
for (Block tube : tubes) {
if(tube.overlaps(Player.getRect()){
dm.set(new OtherState(dm));
}
Ну и создание Rect в классе Player
rect = new Rectangle(x, y, player.getWidth(),player.getHeight());
tubes здесь объект типа Array Block> .dm - сокр. от display manager -- стек экранных состояний. метод set(dm) -- объединение методов pop(dm) и push().
Продвижение своими сайтами как стратегия роста и независимости