Hi , i’ve a problem with the collision with Panel borders …
I post a part of code for every class :
in main class:
GamePanel_1 g = new GamePanel_1();
add(g);
pack();
in Panel class:
public static Dimension size= new Dimension(180,180);
setPreferredSize(size);
in a other class:
if(x>160){
collide=true;
isrunning=false;
x=160;
}
160 is a number calculate like the width of the panel set with setpreferredsize minus the width of my image (20 pixel), the problem is that is like if the panel haven’t the size that I’ve set and so the collision don’t work well