Partage
  • Partager sur Facebook
  • Partager sur Twitter

Code Blocks, bug, renvoit 1 !

Pour un snake.

    12 avril 2006 à 14:52:15

    Voici mon probleme, lorsque j'execute mon programme tout se passe bien, mais la fenetre apparait 1/10 de secondes, et code Blocks me met ca :

    Project : SDL Application
    Compiler : GNU GCC Compiler (called directly)
    Directory : C:\Antoine\Prog\CC++\SDLtest\
    --------------------------------------------------------------------------------
    Checking for existence: SDLtest.exe
    Executing: "C:\Antoine\Prog\CC++\SDLtest\SDLtest.exe" (in .)
    Process terminated with status 1 (0 minutes, 0 seconds)
    0 errors, 0 warnings


    il m'a semble voir que l'on pouvait regler le niveau de "debuggagfe". Cela ets i possible ?

    Cela pourra t il resoudre mon probleme ?




    #include <stdlib.h>
    #include <stdio.h>
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include "fonctionAleatoire.h"
    #define TAILLE_FENETRE 500




    int main(int argc, char *argv[])
    {





        int numeroCouleur = 0;

        SDL_Surface *ecran = NULL, *carre = NULL, *surfaceJeu = NULL, *carreCherche = NULL;
        SDL_Event event;
        int continuer = 1, derniereAction = 0, perdu = 1;
        long points = 0;
        SDL_Rect positionCarre;
        SDL_Rect positionSurfaceJeu;
        SDL_Rect positionCarreCherche;
        long hauteurEcran = TAILLE_FENETRE, largeurEcran = TAILLE_FENETRE;
        Uint32 temps = 0, tempsAttente = 0;


        positionCarreCherche.x = 80;
        positionCarreCherche.y = 40;

        positionSurfaceJeu.x = 20;
        positionSurfaceJeu.y = 20;



        SDL_Init(SDL_INIT_VIDEO);

        ecran = SDL_SetVideoMode(largeurEcran, hauteurEcran, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_NOFRAME);
        SDL_WM_SetCaption("Jeu du montée, descente", NULL);

        positionCarre.x = ecran->w - 40;
        positionCarre.y = ecran->h - 40;

        SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 200, 200, 200));

        carre = SDL_CreateRGBSurface(SDL_HWSURFACE, 20, 20, 32, 0, 0, 0, 0);
        SDL_FillRect(carre, NULL, SDL_MapRGB(carre->format, 255, 0, 0));



        surfaceJeu = SDL_CreateRGBSurface(SDL_HWSURFACE, ecran->w - 40, ecran->h - 40, 32, 0, 0, 0, 0);
        SDL_FillRect(surfaceJeu, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
        SDL_BlitSurface(surfaceJeu, NULL, ecran, &positionSurfaceJeu);

        SDL_EnableKeyRepeat(1000, 100);




        while (continuer + perdu - 1)
        {
            temps = SDL_GetTicks();






                if (event.type == SDL_QUIT)
                {
                        continuer = 0;
                }
                else if(event.type == SDL_KEYDOWN)
                {

                        switch (event.key.keysym.sym)
                        {
                            case SDLK_ESCAPE:
                                continuer = 0;
                                break;
                            case SDLK_UP:
                                if(positionCarre.y == 20)
                                {
                                    perdu = 0;
                                }
                                else
                                {
                                    positionCarre.y -=20;
                                    derniereAction = 1;
                                }
                                break;
                            case SDLK_DOWN:

                                if(positionCarre.y == ecran->h - 40)
                                {
                                    perdu = 0;
                                }
                                else
                                {
                                    positionCarre.y +=20;
                                    derniereAction = 2;
                                }
                                break;

                            case SDLK_RIGHT:
                                if(positionCarre.x == ecran->w - 40)
                                {
                                    perdu = 0;

                                }
                                else
                                {
                                    positionCarre.x +=20;
                                    derniereAction = 3;
                                }
                                break;
                            case SDLK_LEFT:
                                if(positionCarre.x == 20)
                                {
                                    perdu = 0;
                                }
                                else
                                {
                                    positionCarre.x -=20;
                                    derniereAction = 4;
                                }


                                break;
                        }
                }

                else
                {


                        switch (derniereAction)
                            {
                            case 1:
                            if(positionCarre.y == 20)
                            {
                                perdu = 0;
                            }
                            else
                            {
                                positionCarre.y -= 20;
                            }
                            break;

                            case 2:
                            if(positionCarre.y == ecran->h - 40)
                            {
                                perdu = 0;
                            }
                            else
                            {
                                positionCarre.y +=20;
                            }
                            break;

                            case 3:
                            if(positionCarre.x == ecran->w - 40)
                            {
                                perdu = 0;
                            }
                            else
                            {
                                positionCarre.x +=20;
                            }
                            break;

                            case 4:
                            if(positionCarre.x == 20)
                            {
                                perdu = 0;
                            }
                            else
                            {
                                positionCarre.x -=20;
                            }

                            break;
                            }


                    }


            if((tempsAttente = 250 - (SDL_GetTicks() - temps)) > 0);
                    {
                        SDL_Delay(tempsAttente);
                    }
                SDL_PollEvent(&event);



            if(positionCarre.x == positionCarreCherche.x && positionCarre.y == positionCarreCherche.y)
            {

                SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 200, 200, 200));
                SDL_FillRect(surfaceJeu, NULL, SDL_MapRGB(surfaceJeu->format, 255, 255, 255));
                SDL_BlitSurface(surfaceJeu, NULL, ecran, &positionSurfaceJeu);
                SDL_BlitSurface(carre, NULL, ecran, &positionCarre);

                SDL_FillRect(carreCherche, NULL, SDL_MapRGB(carreCherche->format, 255, 255, 0));
                SDL_BlitSurface(carreCherche, NULL, ecran, &positionCarreCherche);
                SDL_Flip(ecran);
            }
            else
            {
                SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 200, 200, 200));
                SDL_FillRect(surfaceJeu, NULL, SDL_MapRGB(surfaceJeu->format, 255, 255, 255));
                SDL_BlitSurface(surfaceJeu, NULL, ecran, &positionSurfaceJeu);
                SDL_BlitSurface(carre, NULL, ecran, &positionCarre);

                SDL_FillRect(carreCherche, NULL, SDL_MapRGB(carreCherche->format, 255, 255, 0));
                SDL_BlitSurface(carreCherche, NULL, ecran, &positionCarreCherche);
                SDL_Flip(ecran);
            }







        }
        SDL_FreeSurface(surfaceJeu);
        SDL_FreeSurface(carre);
        SDL_Quit();
        return EXIT_SUCCESS;
    }


    Merci beaucoup a ceux qui ont pris le tmeps de lire mon code

    Bonne Apres midi !

    El Tonio
    • Partager sur Facebook
    • Partager sur Twitter
      12 avril 2006 à 16:10:22

      Moi aussi j'ai des problemes de Status 1, et je comprends pas pourquoi:
      avec le même code, sans en changer une ligne, ca peut marcher ou planter.Mais exactement le même.Il faut alors que je modifie un ancien programme de SDL qui avait fonctionné et que j'en change le code.Et la ca marche.Alors je copie le code, créé un nouveau projet et colle le code.Et la ca plante.
      Voila je peux rien pour toi mais peut être que nos problemes ont un point commun, enfin moi j'dis ca, j'dis rien ! ^^
      • Partager sur Facebook
      • Partager sur Twitter
        12 avril 2006 à 18:48:11

        C'est juste que tu as un plantage... Utilise le débugger pour voir de quelle fonction ça vient.
        • Partager sur Facebook
        • Partager sur Twitter
          12 avril 2006 à 19:10:49

          A qui parle tu ?
          En tous cas je t'assure que dans les deux mêmes programmes, j'ai deux fois exactement le même code et qu'il y en a un qui ne fonctionne pas. o_O
          • Partager sur Facebook
          • Partager sur Twitter
            12 avril 2006 à 19:37:24

            j'ai supprimle toutes les lignes touchant a carreCherche et allez savoir pourquoi ca remarche !

            sinon, sur CodeBlocks, comment passer le debugger a un niveau superieur de debuggage ?
            • Partager sur Facebook
            • Partager sur Twitter
              12 avril 2006 à 20:14:09

              Citation : El Tonio

              sinon, sur CodeBlocks, comment passer le debugger a un niveau superieur de debuggage ?


              Supérieur à quoi ? Tout ce qu'il faut faire pour pouvoir débugger, c'est activer le mode debug :
              • Clicker sur le projet
              • Click droit
              • Build options
              • Onglet 'Compiler flags', cocher 'Produce debugging symbols'
              • OK

              Ensuite, "exécuter pas à pas" ou "jusqu'au curseur" etc.
              • Partager sur Facebook
              • Partager sur Twitter
              Music only !

              Code Blocks, bug, renvoit 1 !

              × 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