merci beaucoup pour l'aide que tu m'apporte mais le probleme de mon programme ne ce situe pas a ce niveau . en faite le probleme sais que je j'ai deja une bonne partie du code sur a chute de ballle mais j'ai besoin de faire tomber la balle sur le sol avec emission d'un son a chaque fois quelle touche le sol et la balle dois remonter a 2/3 de sa chute jusqu'a un arrete total . mais ce probleme de chuute de balle ne tient pas conmpte des notion de physique ou de math spécialiser sais une chute simple . j'utilise le borlan c++ pour compiler . je te passe le code que j'ai pour te donner une idée . donc comme je t'ai expliquer le but rechercher est de faire rebondire la bale sur le sol jusqu'a un arrete total avec emission de son a chaque fois que la balle touche le sol . voici le code :
/*************************************************************/
/* NOM : EFFA OBAME */
/* PRENOM : PRADINO */
/* EXERCICE : Lancer d'une balle */
/*************************************************************/
#include<graphics.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<dos.h>
#include<math.h>
#include<iostream.h>
class Point
{protected:int x;
int y;
short visible;
int couleur_trace;
public: Point(int initx,int inity);
int getx(void);
int gety(void);
short isvisible(void);
void moveto(int newx,int newy);
};
class Cercle : public Point
{protected:int couleur_plein;
short colorie;
int rayon;
public: Cercle(int initx, int inity, int initradius);
void setfillcolor(int newfillcolor);
void show(void);
void hide(void);
};
class Rectangle : public Point
{protected:int couleur_plein;
short colorie;
int base_x, hauteur_y;
double angle_z;
public: Rectangle(int initx, int inity, int base, int hauteur,double angle);
void setfillcolor(int newfillcolor);
void show(void);
void hide(void);
void moveto(int,int,double);
};
class Homme : public Rectangle
{protected: Cercle tete, poid, oeil, soleil;
Rectangle piedG,piedD,corps,jambeG,jambeD,bra,bouche,pencasquette,casquette;
Rectangle herbe, ciel;
public: Homme(int xcsg,int ycsg,int base,int hauteur,double angle);
void show(void);
void hide(void);
void moveto(int newx,int newy,double newangle);
void movebra(double newangle);
void movepoidetbra(int newx);
void movepoid(int newx);
};
Point :: Point(int initx,int inity)
{x = initx;
y = inity;
visible=0;
couleur_trace = getcolor();
}
int Point :: getx(void)
{return x;
}
int Point :: gety(void)
{return y;
}
short Point :: isvisible(void)
{return visible;
}
void Point :: moveto(int newx, int newy)
{x = newx;
y = newy;
return;
}
Cercle :: Cercle(int initx, int inity, int initradius) : Point(initx, inity)
{rayon = initradius;
couleur_plein = getbkcolor();
colorie=0;
}
void Cercle :: setfillcolor(int newfillcolor)
{colorie=1;
couleur_plein = newfillcolor;
if (isvisible()) show();
return;
}
void Cercle :: show(void)
{setcolor(couleur_trace);
if (colorie)
{setfillstyle(SOLID_FILL,couleur_plein);
fillellipse(x,y,rayon,rayon);
}
else circle(x,y,rayon);
return;
}
void Cercle :: hide(void)
{setcolor(getbkcolor());
if (colorie)
{setfillstyle(EMPTY_FILL, getbkcolor());
fillellipse(x, y, rayon, rayon);
}
else circle(x, y, rayon);
return;
}
Rectangle::Rectangle(int initx, int inity, int base, int hauteur,double angle) :
Point (initx, inity)
{base_x=base;
hauteur_y=hauteur;
angle_z=angle;
colorie=0;
return;
}
void Rectangle::show(void)
{int poly[8];
setcolor(couleur_trace);
if(colorie)
{setfillstyle(SOLID_FILL,couleur_plein);
poly[0]=getx()-base_x/2;
poly[1]=gety();
poly[2]=(getx()-base_x/2)+base_x*cos(angle_z);
poly[3]=gety()-base_x*sin(angle_z);
poly[4]=(getx()-base_x/2)+base_x*cos(angle_z)+hauteur_y*sin(angle_z);
poly[5]=gety()+hauteur_y*cos(angle_z)-base_x*sin(angle_z);
poly[6]=(getx()-base_x/2)+hauteur_y*sin(angle_z);
poly[7]=gety()+hauteur_y*cos(angle_z);
fillpoly(4,poly);
}
else rectangle(x-base_x/2,y,x+base_x/2,y+hauteur_y);
return;
}
void Rectangle::hide(void)
{int poly[8];
setcolor(getbkcolor());
if(colorie)
{setfillstyle(SOLID_FILL,getbkcolor());
poly[0]=getx()-base_x/2;
poly[1]=gety();
poly[2]=(getx()-base_x/2)+base_x*cos(angle_z);
poly[3]=gety()-base_x*sin(angle_z);
poly[4]=(getx()-base_x/2)+base_x*cos(angle_z)+hauteur_y*sin(angle_z);
poly[5]=gety()+hauteur_y*cos(angle_z)-base_x*sin(angle_z);
poly[6]=(getx()-base_x/2)+hauteur_y*sin(angle_z);
poly[7]=gety()+hauteur_y*cos(angle_z);
fillpoly(4,poly);
}
if(angle_z==0) rectangle(getx()-base_x/2,gety(),getx()+base_x/2,gety()+hauteur_y);
return;
}
void Rectangle::setfillcolor(int newfillcolor)
{colorie=1;
couleur_plein=newfillcolor;
if (isvisible()) show();
return;
}
void Rectangle::moveto(int newx,int newy,double newangle)
{hide();
Point::moveto(newx,newy);
angle_z=newangle;
show();
}
Homme::Homme(int xcsg, int ycsg, int base, int hauteur,double angle) :
corps(xcsg,ycsg+50,30,55,0),
jambeG(xcsg,ycsg+100,base/7,55,angle),
jambeD(xcsg,ycsg+100,base/7,55,(-angle)),
piedD(xcsg+32,ycsg+110+(hauteur*cos(angle)),25,12,0),
piedG(xcsg-20,ycsg+90+80-hauteur*sin(angle),25,12,0),
bra(xcsg,ycsg+60, 10, 40, 4),
tete(xcsg, ycsg+33,hauteur/2.7),
soleil(xcsg+8,ycsg-160,hauteur/1.8),
poid(xcsg-30,ycsg+30,hauteur/4-2),
Rectangle(xcsg,ycsg-18,35,80,0),
bouche(xcsg+10,ycsg+38,8,0.5,0),
oeil(xcsg+9,ycsg+28,3),
pencasquette(xcsg+21,ycsg+21,15,3,0),
casquette(xcsg,ycsg+16,27,8,0),
herbe(xcsg+10,ycsg+162,1200,120,0),
ciel(xcsg+10,ycsg-220,1200,40,0)
{
tete.setfillcolor(6);
soleil.setfillcolor(14);
corps.setfillcolor(1);
jambeG.setfillcolor(1);
jambeD.setfillcolor(1);
piedD.setfillcolor(1);
piedG.setfillcolor(1);
bra.setfillcolor(1);
poid.setfillcolor(8);
bouche.setfillcolor(1);
pencasquette.setfillcolor(4);
casquette.setfillcolor(4);
herbe.setfillcolor(18);
ciel.setfillcolor(9);
}
void Homme::show(void)
{
tete.show();
soleil.show();
corps.show();
jambeG.show();
jambeD.show();
piedG.show();
piedD.show();
bra.show();
poid.show();
bouche.show();
oeil.show();
pencasquette.show();
casquette.show();
//ciel.show();
herbe.show();
return;
}
void Homme::hide(void)
{
piedD.hide();
piedG.hide();
jambeG.hide();
jambeD.hide();
corps.hide();
tete.hide();
bra.hide();
poid.hide();
bouche.hide();
oeil.hide();
pencasquette.hide();
casquette.hide();
return;
}
void Homme::moveto(int newx,int newy,double newangle)
{hide();
x=newx;
y=newy;
tete.moveto(newx,tete.gety());
corps.moveto(newx,corps.gety(),0);
jambeG.moveto(newx,jambeG.gety(),newangle);
jambeD.moveto(newx,jambeD.gety(),-newangle);
corps.moveto(newx,corps.gety(),0);
piedD.moveto(newx+55*sin(-newangle),jambeD.gety()+50*cos(newangle),-newangle);
piedG.moveto(newx+55*sin(newangle),jambeG.gety()+50*cos(newangle),newangle);
bra.moveto(newx+10,corps.gety()+10,4);
poid.moveto(newx-30,poid.gety());
oeil.moveto(9+newx,oeil.gety());
bouche.moveto(10+newx,bouche.gety(),0);
pencasquette.moveto(21+newx,pencasquette.gety(),0);
casquette.moveto(newx,casquette.gety(),0);
show();
delay(50);
return;
}
void Homme::movebra(double newangle)
{
bra.moveto(bra.getx(),corps.gety()+10,newangle);
poid.show();
tete.show();
casquette.show();
pencasquette.show();
bouche.show();
oeil.show();
corps.show();
bra.show();
poid.show();
delay(15);
}
void Homme::movepoidetbra(int newx)
{
poid.hide();
poid.moveto(poid.getx()+(newx/2.5),poid.gety()-(pow((newx)/2.5,0.5))*1.2);
poid.show();
delay(50);
}
void Homme::movepoid(int newx)
{
poid.hide();
poid.moveto(poid.getx()+newx,poid.gety()-(pow(newx,0.5))*1.2);
poid.show();
casquette.show();
pencasquette.show();
delay(80);
}
/*******************************************************************/
/* */
/* Programme principal */
/* */
/*******************************************************************/
int main(void)
{int i,j;
int gdriver;
int gmode;
int errorcode;
int cax=40,cay=200,cab=80,cah=45;
double ang=0.5;
gdriver = DETECT;
initgraph(&gdriver,&gmode,"C:\\borlanc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{printf("Erreur graphique: %s\n",grapherrormsg(errorcode));
printf("Taper une touche pour arreter");
printf("\nModifier le chemein d'acces au compilateur dans le programme principale!!!");
getch();
exit(1);
}
setbkcolor(9);
Homme hom(cax,cay,cab,cah,ang);
for(i=0;i<110;i++)
{
ang=0.5;
for(j=0;j<20;j++)
{
ang=ang-0.09;
hom.moveto(cax+i+j,cay,ang);
j++;
}
i=i+15;
}
i=0;
ang=4;
do
{
hom.movebra(ang);
i++;
hom.movepoidetbra(cax+i);
ang=ang-0.5;
}while(ang!=2);
for(i=0;i<11;i++)
{
hom.movepoid(cax+i);
}
getch();
closegraph();
return 0;
}
je compte sur ton aide . je te remerci de tout coeur .