1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| // Classe Ballle : Implementation
//
//************ Constructeur **********
//
Balle::Balle(int x, int y,int r)
{
X=x;
Y=y;
R=r;
dx=dy=0;
}
//
//*********** le déplacement **********
//
void Balle::Bouger()
{
X=X+dx;
Y=Y+dy;
}
//
//****** Changement de direction *******
//
void Balle::direction(int incX, int incY)
{
dx=incX;
dy=incY;
}
//
// le Trace
//
void Balle::Dessiner(CDC *dc)
{
int x1=-R/2+X;
int y1=-R/2+Y;
int x2=R/2+X;
int y2=R/2+Y;
dc->Ellipse(x1,y1,x2,y2);
}
void Balle::condition(terrain stade)
{
if (HautG) ////si la balle a une direction Haut gauche
{if (X==stade.OX-R) {HautG=false; HautD=true;}
/// si elle arrive sur la limite gauche
if (Y==stade.OY+R) {HautG=false; BasG=true;}}
///si elle arrive sur la limite gauche
if (HautD)
{if (X==stade.OX+stade.l-R) {HautD=false; BasD=true; }
if (Y==stade.OY+R) {HautD=false; BasD=true; }}
//
if (BasG)
{if (Y==stade.OY+R) {BasG=false; BasD=true; }
if (X==stade.OX-R) {HautG=false; HautG=true; }}
if (BasD)
{if (Y==stade.OX+stade.l-R) {BasD=false; HautG=true; }
if (X==stade.OY-R) {BasD=false; HautD=true;}}
} |
Partager