Blame view

Monstre/Monstre.c 1.05 KB
2fd95d7e   Martin CHAUVELIERE   1ere Version bis
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
  #include <stdio.h>
  #include <stdlib.h>
  #include "../Graphique/libgraph.h"
  #include "../ListeC/Liste.h"
  #include "Monstre.h"
  
  //sens 1 = Va vers la droite
  void DeplacementLutin(int lutin,struct liste_entite *l, int *psens, int speed)
  {
      int ind=0;
      struct liste_entite *ml=l;
      while(ml != NULL)
      {
          if (*psens==1)
          {
              ml->enti.posx+=speed;
              if(ml->enti.posx>=450)ind=1;
              afficherLutin(lutin,ml->enti.posx,ml->enti.posy);
          }
          else
          {
              ml->enti.posx-=speed;
              if(ml->enti.posx<=50)ind=2;
              afficherLutin(lutin,ml->enti.posx,ml->enti.posy);
          }
          ml=ml->suivant;
      }
      if (ind==1)
      {
          *psens=0;
          struct liste_entite *ml2=l;
          while(ml2 != NULL)
          {
              ml2->enti.posy+=30;
              ml2=ml2->suivant;
          }
      }
      else if (ind==2)
      {
          *psens=1;
          struct liste_entite *ml2=l;
          while(ml2 != NULL)
          {
              ml2->enti.posy+=30;
              ml2=ml2->suivant;
          }
      }
  }