int main(void) {

  srand((unsigned int)time(NULL));
  int snake[TAILLE_SNAKE][2],
      len_snake=10,
      pommes[TAILLE_POMME][2],
      len_pommes=5,
      direction[2]={0,-1},
      score=0,
      done=0;
  unsigned long int tempsDepart=Microsecondes(), tempsActuel,tempsTmp;
  unsigned long int prochainAffichage=0,prochainDeplacement=0;
  initSnake(snake,len_snake);
  initPommes(pommes, len_pommes, snake, len_snake);
  InitialiserGraphique();
  CreerFenetre(BORD,BORD,60*TAILLE_CASE+2*BORD,40*TAILLE_CASE+BORD+40);
  ChoisirEcran(1);/*on dessine tout dans un ecran virtuel (cela joue le role de buffer)
                    puis dans la fonction printScreen on copie l'ecran virtuel sur l'ecran reel*/


  while(!done){
    tempsActuel=Microsecondes();
    if(Microsecondes()>prochainAffichage){
      printScreen(snake, len_snake,  pommes, len_pommes, tempsDepart,tempsActuel, score);
      prochainAffichage=Microsecondes()+CYCLE;
    }
    tempsTmp=Microsecondes();
    GestionTouche(snake, direction, &done);
    tempsDepart+=Microsecondes()-tempsTmp;
    if(Microsecondes()>prochainDeplacement){
      DeplacementSnake(snake, len_snake, direction);
      CheckCollisionBord(snake, &done);
      CheckCollisionPomme(len_pommes, pommes, snake, &len_snake, &score);
      prochainDeplacement=Microsecondes()+100000;
    }
  }
  FermerGraphique();
  return EXIT_SUCCESS;
}
  int main(void) {

    srand((unsigned int)time(NULL));
    int snake[TAILLE_SNAKE][2],
        len_snake=10,
        pommes[TAILLE_POMME][2],
        len_pommes=5,
        direction[2]={0,-1};
    int* score;
    *score=0;
    const unsigned long int tempsDepart=Microsecondes();
    unsigned long int prochainAffichage=0,prochainDeplacement=0;
    initSnake(snake,len_snake);
    initPommes(pommes,len_pommes);
    InitialiserGraphique();
    CreerFenetre(BORD,BORD,60*TAILLE_CASE+2*BORD,40*TAILLE_CASE+BORD+40);
    ChoisirEcran(1);


    /*EffacerEcran(CouleurParNom("black"));
    */
    while(1){
      if(Microsecondes()>prochainAffichage){
        printScreen(snake, len_snake,  pommes, len_pommes, tempsDepart, &score);
        prochainAffichage=Microsecondes()+CYCLE;
      }
      GestionTouche(snake,direction);
      if(Microsecondes()>prochainDeplacement){
        DeplacementSnake(snake,len_snake,direction);
        CheckCollisionBord(snake);
        CheckCollisionPomme(len_pommes,pommes,snake,score);
        prochainDeplacement=Microsecondes()+100000;
      }
      if(ToucheEnAttente()==1 && Touche()==XK_Escape){
        FermerGraphique();
        return EXIT_SUCCESS;
      }
    }
  }
int main(void){

  srand((unsigned int)time(NULL));
  int snake[TAILLE_SNAKE][2],
      len_snake=10,
      pommes[TAILLE_POMME][2],
      len_pommes=5,
      direction[2]={0,-1};
  int score=0;
  int *pointeurScore= &score, *pointeurLenSnake=&len_snake;
  const unsigned long int tempsDepart=Microsecondes();
  unsigned long int prochainAffichage=0,prochainDeplacement=0;
  
  initSnake(snake,len_snake);
  initPommes(pommes,len_pommes,snake);
  InitialiserGraphique();
  CreerFenetre(BORD,BORD,60*TAILLE_CASE+2*BORD,40*TAILLE_CASE+BORD+40);
  CreerFenetre(BORD,BORD,60*TAILLE_CASE+2*BORD,40*TAILLE_CASE+BORD+40);
  ChoisirEcran(1);


  /*EffacerEcran(CouleurParNom("black"));
  */
  while(1){
    if(Microsecondes()>prochainAffichage){
      ActualiserPosPomme(pommes,len_pommes,snake);
      printScreen(snake, len_snake,  pommes, len_pommes, tempsDepart, score);
      prochainAffichage=Microsecondes()+CYCLE;
    }
    GestionTouche(snake,direction);
    if(Microsecondes()>prochainDeplacement){
      DeplacementSnake(snake,len_snake,direction);
      CheckCollisionBord(snake);
      CheckCollisionPomme(len_pommes,pommes,snake,pointeurLenSnake,pointeurScore);
      prochainDeplacement=Microsecondes()+100000;
    }
    QuitterSnake();
  }
}
Beispiel #4
0
void buff_segment (int x, int y, int xx, int yy, couleur_role c)
{
	ChoisirEcran(SCR_BUFF);
	ChoisirCouleurDessin(palette[c]);
	DessinerSegment(x,y,xx,yy);
}
Beispiel #5
0
void buff_rect (int x, int y, int w, int h, couleur_role c)
{
	ChoisirEcran(SCR_BUFF);
	ChoisirCouleurDessin(palette[c]);
	RemplirRectangle (x,y,w,h);
}
Beispiel #6
0
void buff_ecrire_texte (char * texte, int x, int y, int taille, couleur_role c)
{
	ChoisirEcran (SCR_BUFF);
	ChoisirCouleurDessin(palette[c]);
	EcrireTexte(x,y,texte,taille);
}