Should thought I’d share this with you all, enjoy!
public void moveUp(Vector<Thing> things){
y += speed;
for(int i = 0; i < things.size(); i++){
if(new Rectangle((int) x, (int) y, width, height).intersects(new Rectangle((int) things.get(i).x, (int) things.get(i).y, things.get(i).width, things.get(i).height))){
y += (things.get(i).y + things.get(i).height) - y;
}
}
}
Okay, so first you move. than you check if you’re hitting anything by using Rectangle.intersects(Rectangle r), than if you are you change your y to right in front of the thing by saying your movement variable (x or y) is +/- the length inside your items line is in the collided item.