Partage
  • Partager sur Facebook
  • Partager sur Twitter

Problème éditeur de niveau

encore -_-

    20 février 2012 à 0:29:43

    Bonsoir , j'ai encore un mini problème avec mon éditeur :
    Image utilisateur
    Je crée quelques carrés .
    Image utilisateur
    Je rajoute un carré (pas celui à côté de couche : 0)
    Image utilisateur
    Je scrolle une fois et regardais ce que je vois 0_o -> un tile qui s'est incrusté à droite .
    Et si je l'efface ... celui à gauche aussi U_U
    (La limite du scroll c'est décaler qu'une seule fois)

    Voici mon code !
    if (input->droite)
        {
           map->mapgame.scrool.varx ++;
            if(map->mapgame.scrool.varx >= map->mapgame.infos.largeur / 32 + 1)
            {
                map->mapgame.scrool.varx = map->mapgame.infos.largeur / 32;
                input->droite = 0;
                return;
            }
            map->mapgame.scrool.xscrool += 32;
            input->droite = 0;
        }
        if (input->gauche)
        {
            if(map->mapgame.scrool.varx <= MAP_LG)
            {
                map->mapgame.scrool.varx = MAP_LG;
                input->gauche = 0;
                return;
            }
            map->mapgame.scrool.xscrool -= 32;
            map->mapgame.scrool.varx --;
            input->gauche = 0;
        }
        if(input->up)
        {
            if(map->mapgame.scrool.vary <= MAP_HT)
            {
                map->mapgame.scrool.vary = MAP_HT;
                input->up = 0;
                return;
            }
            map->mapgame.scrool.yscrool -= 32;
            map->mapgame.scrool.vary --;
            input->up = 0;
        }
        if(input->down)
        {
            map->mapgame.scrool.vary +=1;
            if(map->mapgame.scrool.vary >= map->mapgame.infos.hauteur / 32 + 1)
            {
                map->mapgame.scrool.vary = map->mapgame.infos.hauteur / 32;
                input->down = 0;
                return;
            }
            map->mapgame.scrool.yscrool += 32;
            input->down = 0;
        }
    


    void draw_map(Map *map)
    {
        SDL_Rect dest;
        SDL_Rect src;
        int minx , maxx , miny , maxy;
        int j, i,c;
        src.h = 32;
        src.w = 32;
        minx = map->mapgame.scrool.xscrool / TILE_LG;
        miny = map->mapgame.scrool.yscrool / TILE_HT;
        maxx = (map->mapgame.scrool.xscrool + map->mapgame.scrool.largeurScrool) / TILE_LG;
        maxy = (map->mapgame.scrool.yscrool + map->mapgame.scrool.hauteurScrool) / TILE_HT;
    
        window_pos(map);
    
        for ( c = 0; c < NB_COUCHE; c++)
        {
            for(j = miny ; j < maxy; j++ )
            {
                for(i = minx; i < maxx ; i ++)
                {
                    dest.x = i * 32 - map->mapgame.scrool.xscrool;
                    dest.y = j * 32 - map->mapgame.scrool.yscrool;
                    src.x = map->mapgame.carte[0][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                    src.y = map->mapgame.carte[0][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                    SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                }
            }
        }
        for ( c = 0; c < NB_COUCHE; c++)
        {
            for(j = miny ; j < maxy; j++ )
            {
                for(i = minx; i < maxx ; i ++)
                {
                    dest.x = i * 32 - map->mapgame.scrool.xscrool;
                    dest.y = j * 32 - map->mapgame.scrool.yscrool;
                    src.x = map->mapgame.carte[1][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                    src.y = map->mapgame.carte[1][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                    SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                }
            }
        }
        for ( c = 0; c < NB_COUCHE; c++)
        {
            for(j = miny ; j < maxy; j++ )
            {
                for(i = minx; i < maxx ; i ++)
                {
                    dest.x = i * 32 - map->mapgame.scrool.xscrool;
                    dest.y = j * 32 - map->mapgame.scrool.yscrool;
                    src.x = map->mapgame.carte[2][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                    src.y = map->mapgame.carte[2][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                    SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                }
            }
        }
    }
    



    sans déconner ça fait deux heures que je cherche parce que à chaque fois je me dit. "Ne quitte pas , ça ce trouve si tu reste 5 min de plus tu corrige le bug"

    Vraiment merci à la perle argentée qui m'aideras .
    @+
    • Partager sur Facebook
    • Partager sur Twitter
      20 février 2012 à 10:44:27

      Bonjour,

      Dans le premier bout de code, tu incrémentes des variables "map->mapgame.scrool.varx" et "vary" dont tu ne détailles pas l'utilisation. (Les tests sur MAP_LG et MAP_HT me paraissent étranges, mais bref...).

      Dans la fonction draw_map, 2 choses :

      Tu calcules les minx, miny, maxx et maxy pour l'affichage.
      Très bien, sauf qu'ensuite tu appelles "window_pos(map);", qui doit possiblement modifier map->mapgame.scrool.xscrool et yscrool, variables que tu utilises dans les boucles. Donc il y a un souci.

      A mon avis, tu devrais appeler window_pos AVANT de calculer minx etc. (Cette conversation me rappelle d'ailleurs quelque chose... :-° ).


      Les boucles :
      Tu as 3 blocs : "for ( c = 0; c < NB_COUCHE; c++)"
      Dans chaque bloc, tu n'utilises pas 'c'.
      Donc ce for ne sert à rien.

      Tu es sûr que ce n'est pas "map->mapgame.carte[c]" (et un seul bloc) que tu voulais écrire et pas "map->mapgame.carte[0, 1 et 2]" ?

      A mon avis, en l'état actuel, tu blittes 3 fois chaque couche...

      Clément.
      • Partager sur Facebook
      • Partager sur Twitter
        20 février 2012 à 13:24:40

        Citation : joe78

        Bonjour,

        Dans le premier bout de code, tu incrémentes des variables "map->mapgame.scrool.varx" et "vary" dont tu ne détailles pas l'utilisation. (Les tests sur MAP_LG et MAP_HT me paraissent étranges, mais bref...).

        Dans la fonction draw_map, 2 choses :

        Tu calcules les minx, miny, maxx et maxy pour l'affichage.
        Très bien, sauf qu'ensuite tu appelles "window_pos(map);", qui doit possiblement modifier map->mapgame.scrool.xscrool et yscrool, variables que tu utilises dans les boucles. Donc il y a un souci.

        A mon avis, tu devrais appeler window_pos AVANT de calculer minx etc. (Cette conversation me rappelle d'ailleurs quelque chose... :-° ).


        Les boucles :
        Tu as 3 blocs : "for ( c = 0; c < NB_COUCHE; c++)"
        Dans chaque bloc, tu n'utilises pas 'c'.
        Donc ce for ne sert à rien.

        Tu es sûr que ce n'est pas "map->mapgame.carte[c]" (et un seul bloc) que tu voulais écrire et pas "map->mapgame.carte[0, 1 et 2]" ?

        A mon avis, en l'état actuel, tu blittes 3 fois chaque couche...

        Clément.



        Merci :)
        Alors :
        Dans le premier bout de code, tu incrémentes des variables "map->mapgame.scrool.varx" et "vary" dont tu ne détailles pas l'utilisation. (Les tests sur MAP_LG et MAP_HT me paraissent étranges, mais bref...).
        


        Enfaite c'est ça :
        void init_scrool(Map *map)
        {
            map->mapgame.scrool.largeurScrool = map->mapgame.infos.largeur;
            map->mapgame.scrool.hauteurScrool = map->mapgame.infos.hauteur;
            map->mapgame.scrool.xscrool = 0;
            map->mapgame.scrool.yscrool = 0;
        
            map->mapgame.scrool.varx = MAP_LG;
            map->mapgame.scrool.vary = MAP_HT;
        }
        


        Donc avec l'éditeur on commence tout le temps en haut à gauche .
        Et pour décaler d'un bloc de 32 pixel on fait :
        map->mapgame.scrool.varx = MAP_LG + 1;
        


        Je sais pas si ta compris :s

        Tu calcules les minx, miny, maxx et maxy pour l'affichage.
        Très bien, sauf qu'ensuite tu appelles "window_pos(map);", qui doit possiblement modifier map->mapgame.scrool.xscrool et yscrool, variables que tu utilises dans les boucles. Donc il y a un souci.
        


        Bah j'ai modifié et ça na rien changé .
        Mon windows_pos sert juste à limiter le scrolling :
        void window_pos(Map *map)
        {
            if (map->mapgame.scrool.xscrool < 0)
            {
                map->mapgame.scrool.xscrool = 0;
            }
            if (map->mapgame.scrool.yscrool < 0)
            {
                map->mapgame.scrool.yscrool = 0;
            }
        }
        


        Citation

        A mon avis, tu devrais appeler window_pos AVANT de calculer minx etc. (Cette conversation me rappelle d'ailleurs quelque chose... ).



        Oui en effet désolé ^^'

        Citation

        Les boucles :
        Tu as 3 blocs : "for ( c = 0; c < NB_COUCHE; c++)"
        Dans chaque bloc, tu n'utilises pas 'c'.
        Donc ce for ne sert à rien.

        Tu es sûr que ce n'est pas "map->mapgame.carte[c]" (et un seul bloc) que tu voulais écrire et pas "map->mapgame.carte[0, 1 et 2]" ?

        A mon avis, en l'état actuel, tu blittes 3 fois chaque couche...



        Ah c'est pour ça que ça laggais quand y avais trop de trucs blitter !!
        C'est corrigé!

        Par contre ça me fait toujours le même bug -> un tile apparait alors que je ne l'ai pas appelé .
        • Partager sur Facebook
        • Partager sur Twitter
          20 février 2012 à 13:25:50

          houula je pense qu'il y a un peu de redondance de code non?

          I) tes boucles for on le même conditions -> tu peux les factoriser
          (plus que 3 boucles for au lieu de 9)

          //factorisation brutale
          for ( c = 0; c < NB_COUCHE; c++)
              {
                  for(j = miny ; j < maxy; j++ )
                  {
                      for(i = minx; i < maxx ; i ++)
                      {
                          dest.x = i * 32 - map->mapgame.scrool.xscrool;
                          dest.y = j * 32 - map->mapgame.scrool.yscrool;
          //on peut encore réduire ici à l'aide d'une boucle for
                          src.x = map->mapgame.carte[0][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                          src.y = map->mapgame.carte[0][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                          src.x = map->mapgame.carte[1][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                          src.y = map->mapgame.carte[1][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                          src.x = map->mapgame.carte[2][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                          src.y = map->mapgame.carte[2][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                          SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                      }
                  }
              }
          


          où alors je me trompe en lisant ton code...
          • Partager sur Facebook
          • Partager sur Twitter
            20 février 2012 à 13:28:02

            Non c'est pas possible de faire ça je pense . Ou si mais il faut plusieurs variables src du coup ?
            • Partager sur Facebook
            • Partager sur Twitter
              20 février 2012 à 20:09:06

              Bonsoir,

              Citation : Homer-Hero

              Je sais pas si ta compris :s

              Non c'est sûr, et puisque tes variables "map->mapgame.scrool.varx" et "vary" n'apparaissent ni dans ta routine d'affichage ni dans "window_pos", je ne vois pas pourquoi elles influeraient sur le décalage.

              Sinon à la lecture des messages précédents, je précise mon idée :
              for ( c = 0; c < NB_COUCHE; c++)
                  {
                      for(j = miny ; j < maxy; j++ )
                      {
                          for(i = minx; i < maxx ; i ++)
                          {
                              dest.x = i * 32 - map->mapgame.scrool.xscrool;
                              dest.y = j * 32 - map->mapgame.scrool.yscrool;
                              src.x = map->mapgame.carte[c][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                              src.y = map->mapgame.carte[c][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                              SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                          }
                      }
                  }
              
              Une fois. A moins que mapgame.carte[x] ne corresponde pas au plan ?

              Pour ta case à droite, je pense que tu débordes de ton tableau et que tu affiches la première case de la ligne suivante.
              Pour en être sûr, tu peux rajouter ceci après le calcul de maxx et maxy :
              if (maxx > MAP_LG-1) maxx = MAP_LG-1;
              if (maxy > MAP_HT-1) maxx = MAP_HT-1;

              Clément.
              • Partager sur Facebook
              • Partager sur Twitter
                20 février 2012 à 20:17:46

                J'ai compris pour les boucles d'affichages merci ;)

                Citation

                Pour ta case à droite, je pense que tu débordes de ton tableau et que tu affiches la première case de la ligne suivante.
                Pour en être sûr, tu peux rajouter ceci après le calcul de maxx et maxy :
                if (maxx > MAP_LG-1) maxx = MAP_LG-1;
                if (maxy > MAP_HT-1) maxx = MAP_HT-1;



                Ah oui apparament , je déborde du tableau mais la avec :
                Pour ta case à droite, je pense que tu débordes de ton tableau et que tu affiches la première case de la ligne suivante.
                Pour en être sûr, tu peux rajouter ceci après le calcul de maxx et maxy :
                if (maxx > MAP_LG-1) maxx = MAP_LG-1;
                if (maxy > MAP_HT-1) maxx = MAP_HT-1;
                


                ça ne scroll plus :s

                Merci vraiment :)
                • Partager sur Facebook
                • Partager sur Twitter
                  20 février 2012 à 21:04:15

                  Re,

                  Et en corrigeant ma faute de frappe ?

                  if (maxx > MAP_LG-1) maxx = MAP_LG-1;
                  if (maxy > MAP_HT-1) maxy = MAP_HT-1;

                  Peux-tu poster ton draw_map actuel ?

                  Clément.
                  • Partager sur Facebook
                  • Partager sur Twitter
                    20 février 2012 à 21:08:36

                    Bah je le mettais déjà enfaite en gros j'ai :
                    if (input->droite)
                        {
                           map->mapgame.scrool.varx ++;
                            if(map->mapgame.scrool.varx > MAP_LG - 1)
                            {
                                map->mapgame.scrool.varx = MAP_LG - 1;
                                input->droite = 0;
                                return;
                            }
                            map->mapgame.scrool.xscrool += 32;
                            input->droite = 0;
                        }
                        if (input->gauche)
                        {
                            if(map->mapgame.scrool.varx <= MAP_LG - 1)
                            {
                                map->mapgame.scrool.varx = MAP_LG - 1;
                                input->gauche = 0;
                                return;
                            }
                            map->mapgame.scrool.xscrool -= 32;
                            map->mapgame.scrool.varx --;
                            input->gauche = 0;
                        }
                    


                    Pour le y je m'en occupe plus tard , je le fait d'abord pour les x :)

                    Le draw c'est ça :
                    void draw_map(Map *map)
                    {
                        SDL_Rect dest;
                        SDL_Rect src;
                        int minx , maxx , miny , maxy;
                        int j, i,c;
                        src.h = 32;
                        src.w = 32;
                        window_pos(map);
                        minx = map->mapgame.scrool.xscrool / TILE_LG;
                        miny = map->mapgame.scrool.yscrool / TILE_HT;
                        maxx = (map->mapgame.scrool.xscrool + map->mapgame.scrool.largeurScrool) / TILE_LG;
                        maxy = (map->mapgame.scrool.yscrool + map->mapgame.scrool.hauteurScrool) / TILE_HT;
                    
                        for(j = miny ; j < maxy; j++ )
                        {
                            for(i = minx; i < maxx ; i ++)
                            {
                                dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                src.x = map->mapgame.carte[0][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                src.y = map->mapgame.carte[0][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                            }
                        }
                        for(j = miny ; j < maxy; j++ )
                        {
                            for(i = minx; i < maxx ; i ++)
                            {
                                dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                src.x = map->mapgame.carte[1][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                src.y = map->mapgame.carte[1][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                            }
                        }
                        for(j = miny ; j < maxy; j++ )
                        {
                            for(i = minx; i < maxx ; i ++)
                            {
                                dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                src.x = map->mapgame.carte[2][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                src.y = map->mapgame.carte[2][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                            }
                        }
                    }
                    


                    Peut-être que j'ai pas bien compris ? :o
                    • Partager sur Facebook
                    • Partager sur Twitter
                      20 février 2012 à 21:30:02

                      Re,

                      Bon, j'ai enfin compris à quoi servaient tes variables scrool.varx et vary. Donc première chose à faire, tu les éradiques complètement.

                      Il restera sûrement qqchose dans le genre :
                      if (input->droite)
                      {
                         if (map->mapgame.scrool.xscroll + map->mapgame.scrool.largeurScrool + TILE_LG < (MAP_LG - 1) * TILE_LG)
                            map->mapgame.scrool.xscroll += TILE_LG;
                         input->droite = 0;
                      }
                      

                      Après je ne saisis pas bien ce que sont MAP_LG et MAP_HT. Si ce sont des define, ça veut dire que toutes tes maps ont la même dimension ?

                      Je déduis aussi de ton affichage que "map->mapgame.scrool.largeurScrool" est la largeur affichée à l'écran. Ca pour le coup, ça serait mieux en define.

                      Clément.
                      • Partager sur Facebook
                      • Partager sur Twitter
                        20 février 2012 à 21:53:07

                        Alors j'ai mis ça :
                        if (input->droite)
                            {
                               if (map->mapgame.scrool.xscrool + map->mapgame.scrool.largeurScrool + TILE_LG < (MAP_LG - 1) * TILE_LG)
                                  map->mapgame.scrool.xscrool += TILE_LG;
                               input->droite = 0;
                            }
                            if (input->gauche)
                            {
                                if (map->mapgame.scrool.xscrool + map->mapgame.scrool.largeurScrool + TILE_LG < (MAP_LG - 1) * TILE_LG)
                                  map->mapgame.scrool.xscrool -= TILE_LG;
                               input->droite = 0;
                            }
                        


                        Citation

                        Après je ne saisis pas bien ce que sont MAP_LG et MAP_HT. Si ce sont des define, ça veut dire que toutes tes maps ont la même dimension ?


                        ça c'est les valeurs minimum de chaque map :

                        map->mapgame.scrool.largeurScrool = map->mapgame.infos.largeur;
                            map->mapgame.scrool.hauteurScrool = map->mapgame.infos.hauteur;
                            map->mapgame.scrool.xscrool = 0;
                            map->mapgame.scrool.yscrool = 0;
                        


                        Là largeurScrool c'est la hauteur et largeur de la map donc ça peut être très grand .

                        Sinon j'ai changé le droite et gauche mais ça scroll toujours pas .

                        • Partager sur Facebook
                        • Partager sur Twitter
                          21 février 2012 à 10:53:11

                          Bonjour,

                          Bon, c'est clair, je ne comprends rien à tes variables (nommage et valeurs). Je vais donc écrire en français, tu feras la conversion.

                          Pour la gestion clavier, tu as fais n'importe quoi, tu as recopié 2 fois le même bloc.
                          Je pensais à un truc dans le genre :
                          if (input->droite)
                              {
                                 if (map->mapgame.scrool.xscrool + largeur affichée à l'écran en pixels < largeur de la map en pixels)
                                    map->mapgame.scrool.xscrool += TILE_LG;
                                 input->droite = 0;
                              }
                              if (input->gauche)
                              {
                                  if (map->mapgame.scrool.xscrool > 0)
                                    map->mapgame.scrool.xscrool -= TILE_LG;
                                 input->gauche = 0;
                              }
                          

                          Pour le draw :
                          void draw_map(Map *map)
                          {
                              SDL_Rect dest;
                              SDL_Rect src;
                              int minx , maxx , miny , maxy;
                              int j, i,c;
                              SDL_Surface *pScreen = SDL_GetVideoSurface();
                          
                              src.h = 32;
                              src.w = 32;
                          
                              minx = map->mapgame.scrool.xscrool / TILE_LG;
                              miny = map->mapgame.scrool.yscrool / TILE_HT;
                              maxx = (map->mapgame.scrool.xscrool + largeur affichée à l'écran en pixels) / TILE_LG;
                              maxy = (map->mapgame.scrool.yscrool + hauteur affichée à l'écran en pixels) / TILE_HT;
                          
                              si (maxx > largeur de la map en blocs) maxx = largeur de la map en blocs;
                              si (maxy > hauteur de la map en blocs) maxy = hauteur de la map en blocs;
                          
                              for(c = 0; c < NB_COUCHES; c++)
                              for(j = miny; j < maxy; j++)
                              {
                                  for(i = minx; i < maxx; i++)
                                  {
                                      dest.x = (i * TILE_LG) - map->mapgame.scrool.xscrool;
                                      dest.y = (j * TILE_HT) - map->mapgame.scrool.yscrool;
                                      src.x = map->mapgame.carte[c][j][i] % NB_TILE_TILESET_LARGEUR * TILE_LG;
                                      src.y = map->mapgame.carte[c][j][i] / NB_TILE_TILESET_HAUTEUR * TILE_HT;
                                      SDL_BlitSurface(map->mapgame.tileset , &src , pScreen , &dest);
                                  }
                              }
                          }
                          
                          Après, à toi de chercher un peu.

                          Clément.
                          • Partager sur Facebook
                          • Partager sur Twitter
                            21 février 2012 à 11:22:29

                            S je dessine sur la ligne au fond ça me le fait sur la première ligne en x . Voici le code :
                            SDL_Rect dest;
                                SDL_Rect src;
                                int minx , maxx , miny , maxy;
                                int j, i,c;
                                src.h = 32;
                                src.w = 32;
                                minx = map->mapgame.scrool.xscrool / TILE_LG;
                                miny = map->mapgame.scrool.yscrool / TILE_HT;
                                maxx = (map->mapgame.scrool.xscrool + map->mapgame.scrool.largeurScrool) / TILE_LG;
                                maxy = (map->mapgame.scrool.yscrool + map->mapgame.scrool.hauteurScrool) / TILE_HT;
                            
                                window_pos(map);
                            
                                if (maxx > map->mapgame.scrool.largeurScrool / 32)
                                    maxx = map->mapgame.scrool.largeurScrool / 32;
                                if (maxy > map->mapgame.scrool.hauteurScrool / 32)
                                    maxy = map->mapgame.scrool.hauteurScrool / 32;
                            
                                for(j = miny ; j < maxy; j++ )
                                {
                                    for(i = minx; i < maxx ; i ++)
                                    {
                                        dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                        dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                        src.x = map->mapgame.carte[0][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                        src.y = map->mapgame.carte[0][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                        SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                                    }
                                }
                                for(j = miny ; j < maxy; j++ )
                                {
                                    for(i = minx; i < maxx ; i ++)
                                    {
                                        dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                        dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                        src.x = map->mapgame.carte[1][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                        src.y = map->mapgame.carte[1][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                        SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                                    }
                                }
                                for(j = miny ; j < maxy; j++ )
                                {
                                    for(i = minx; i < maxx ; i ++)
                                    {
                                        dest.x = i * 32 - map->mapgame.scrool.xscrool;
                                        dest.y = j * 32 - map->mapgame.scrool.yscrool;
                                        src.x = map->mapgame.carte[2][j][i] % NB_TILE_TILESET_LARGEUR * 32;
                                        src.y = map->mapgame.carte[2][j][i] / NB_TILE_TILESET_HAUTEUR * 32;
                                        SDL_BlitSurface(map->mapgame.tileset , &src , SDL_GetVideoSurface() , &dest);
                                    }
                                }
                            


                            Merci :!
                            • Partager sur Facebook
                            • Partager sur Twitter
                              21 février 2012 à 14:08:36

                              Wah, c'est rigolo comme ton "draw_map" ne ressemble pas du tout à celui que j'ai posté plus haut...

                              Le pointeur écran que j'avais rajouté a disparu, les 3 boucles sont revenues au lieu d'une seule, les chiffres magiques aussi (mea culpa, j'en ai oublié 2 aux lignes 9 et 10), c'est en plus le retour de "window_pos" qui ne sert en l'état actuel à rien et qui est de nouveau mal placée.

                              En plus tu utilises toujours les variables 'largeurScrool' qui représente la largeur de la map(*), alors qu'il faudrait la largeur affichée à l'écran.
                              (*) =

                              Citation : Homer-Hero

                              Là largeurScrool c'est la hauteur et largeur de la map donc ça peut être très grand .


                              Bon, ben moi je vais me faire cuire un oeuf. :-°

                              Bon courage.

                              Clément.
                              • Partager sur Facebook
                              • Partager sur Twitter
                                21 février 2012 à 14:17:01

                                J'ai fait comme ça : désolé ^^'
                                void draw_map(Map *map)
                                {
                                    SDL_Rect dest;
                                    SDL_Rect src;
                                    int minx , maxx , miny , maxy;
                                    int j, i,c;
                                    SDL_Surface *pScreen = SDL_GetVideoSurface();
                                
                                    src.h = 32;
                                    src.w = 32;
                                
                                    minx = map->mapgame.scrool.xscrool / TILE_LG;
                                    miny = map->mapgame.scrool.yscrool / TILE_HT;
                                    maxx = (map->mapgame.scrool.xscrool + LARGEUR) / TILE_LG;
                                    maxy = (map->mapgame.scrool.yscrool + HAUTEUR) / TILE_HT;
                                
                                    if (maxx > MAP_LG) maxx = MAP_LG;
                                    if (maxy > MAP_HT) maxy = MAP_HT;
                                
                                    for(c = 0; c < NB_COUCHE; c++)
                                    for(j = miny; j < maxy; j++)
                                    {
                                        for(i = minx; i < maxx; i++)
                                        {
                                            dest.x = (i * TILE_LG) - map->mapgame.scrool.xscrool;
                                            dest.y = (j * TILE_HT) - map->mapgame.scrool.yscrool;
                                            src.x = map->mapgame.carte[c][j][i] % NB_TILE_TILESET_LARGEUR * TILE_LG;
                                            src.y = map->mapgame.carte[c][j][i] / NB_TILE_TILESET_HAUTEUR * TILE_HT;
                                            SDL_BlitSurface(map->mapgame.tileset , &src , pScreen , &dest);
                                        }
                                    }
                                }
                                


                                Mais je peux pas dessiner sur la dernière ligne .
                                Si je dessine quand meme sur la dernière ligne : ça dessine sur la première ligne et si j'éfface alors qu'il y a rien la dernière ligne : la première ligne s'éfface.

                                Je comprend pas pourquoi ça fait ça :(

                                Sinon je te conseille une omelette ^^



                                J'AI RESOLU LE PROBLEME !!!
                                C'est parce que le tableau était pas assez grand x)
                                Merci est promis la prochaine fois je ferrais un effort .
                                Desolé et remerci :)
                                • Partager sur Facebook
                                • Partager sur Twitter

                                Problème éditeur de niveau

                                × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                                × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                                • Editeur
                                • Markdown