Bon, c'est encore moi !
Je dois rendre mon projet la semaine prochaine, donc je suis un peu dans la merde, désolé de vous embêtez...
Cela concerne un jeu de golf.
J'ai deux thread qui affichent qqch et je voudrais une class qui puissent m'afficher tout (a partir de ces 2 class) dans une seule frame.
j'ai juste laisser le code de start();
Merci beaucoup...
j'ai deux classes, BALLE qui est un thread ou il y a une balle qui avance :
public void start() {
while (true){
for (int i=(int)ballX;i<getWidth();i++) {
ballX = i;
ballY = f(ballX);
System.out.println(+ballX+","+ballY);
System.out.println(+getWidth());
repaint();
try {
Thread.sleep(300);
if(f(ballX)>=80){
break;
}
}
catch (InterruptedException e) {}
}
}
}
Et la classe PARCOURS qui est le parcours de mon jeu :
public void start() {
Graphics g = getGraphics();
Color Bleu=new Color(219,255,255);
g.setColor(Bleu);
g.fillRect(0,0,1024,768);
Color Vert=new Color(9,67,1);
g.setColor(Vert);
double temp=Math.random();
int n=600;
double x=X_MIN;
double t=10*temp+1;
double w=f(t*x);
double h=(X_MAX-X_MIN)/(n-1);
g.fillRect(0,toScreenY(Y_MIN+2.5),50,toScreenY(Y_MIN+3)+toScreenY(Y_MIN+1.5));
double varx=0;
double varw=0;
for (int i=0;i<n-110;i++) {
double xi=X_MIN+i*h;
double wi=f(2*temp*xi);
g.drawLine(toScreenX(x)+50,toScreenY(w),toScreenX(xi)+50,toScreenY(wi));
g.fillRect(toScreenX(x)+50,toScreenY(w),toScreenX(xi)-toScreenX(x),toScreenY(wi)+toScreenY(Y_MIN+1.5));
x=xi;
w=wi;
varx=xi;
varw=wi;
}
g.fillRect(toScreenX(varx)+50,toScreenY(varw),30,toScreenY(varw)+toScreenY(Y_MIN+1.5));
g.fillRect(toScreenX(varx)+80,toScreenY(varw)+40,30,toScreenY(varw)+toScreenY(Y_MIN+1.5));
g.fillRect(toScreenX(varx)+110,toScreenY(varw),70,toScreenY(varw)+toScreenY(Y_MIN+1.5));
g.drawLine(toScreenX(varx)+95,toScreenY(varw)+40,toScreenX(varx)+95,toScreenY(varw)-60);
}