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
|
typedef struct {
Coordonnees pos;
vitesse v;
} Item;
typedef struct {
int x;
int y;
} Coordonnees;
typedef struct {
Gpl g;
int Nb;
Item tab[];
} Donnees;
typedef struct {
Coordonnees pos;
int NbVies;
} Gpl;
void Touche(Widget w, char *input, int up_or_down, void *data) {
Donnees *don = (Donnees *) data;
if (up_or_down == 1) {
const char *test = input;
if (strcmp(test, "z") == 0) {
Avancer(don);
redisplay(w, Largeur, Longueur, don);
}
Deplacer(don);
}
}
void Deplacer(Donnees *d) {
int i;
for (i=0; i<d->NbCochons; i++) {
Item co = d->tab[i];
Gpl gp = d->g;
int x = co.pos.x - gp.pos.x;
int y = co.pos.y - gp.pos.y;
double dx = (double)x;
double dy = (double)y;
double angle = atan2(dy, dx);
printf("angle : %f \n", angle);
}
} |
Partager