Partage
  • Partager sur Facebook
  • Partager sur Twitter

Les fonctions c'est pas mon truc :(

Sujet résolu
    15 avril 2006 à 0:15:58

    Salut à tous, je cherche à faire une fonction blit, mais la compilation echoue :( :

    #include <stdlib.h>
    #include <math.h>
    #include <stdio.h>
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include "prototypes.h"
    #define MENU 1
    #define JEU 2
    #define OPTION 3


    void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect position)
    {

        SDL_BlitSurface(image, NULL, surface, &position);
    }


    Et l'appel de la fonction :

    blit(imgChoix, ecran, &positionChoix);


    Merci infinement de votre aide, j'ai tout essayer :'(
    • Partager sur Facebook
    • Partager sur Twitter
      15 avril 2006 à 0:27:36

      tu pourrais nous donner les erreur de compilation? et le code complet?
      • Partager sur Facebook
      • Partager sur Twitter
        15 avril 2006 à 0:31:30

        Bien sûr :

        Les erreurs :

        Compile le fichier de fonctions :

        Compiling: Codeblocs\projet1\fonctions.c
        Linking console executable: Codeblocs\projet1\fonctions.exe
        Codeblocs\projet1\fonctions.o:fonctions.c:(.text+0x23): undefined reference to `SDL_UpperBlit'
        d:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
        collect2: ld returned 1 exit status
        Process terminated with status 1 (0 minutes, 0 seconds)
        0 errors, 0 warnings

        Compile le main.c :

        Que des warnings...

        Code complet :

        main.c :

        #include <stdlib.h>
        #include <math.h>
        #include <stdio.h>
        #include <SDL/SDL.h>
        #include <SDL/SDL_image.h>
        #include "prototypes.h"
        #define DISTANCE 3
        #define VITESSE 1
        #define ENNEMIX 168
        #define ENNEMIY 216
        #define LARGEUR 1000
        #define HAUTEUR 740
        #define SCORE 20
        #define MENU 1
        #define JEU 2
        #define OPTIONS 3


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

            SDL_Surface *ecran = NULL, *img = NULL, *fond = NULL, *imgFond = NULL, *viseur = NULL, *imgChoix = NULL, *imgHs = NULL, *imgOs = NULL, *imgExit = NULL, *img10 = NULL, *img20 = NULL, *img50 = NULL, *imgIni = NULL, *imgLow = NULL, *imgMiddle = NULL, *imgHigh = NULL, *imgAk = NULL, *imgScout = NULL, *imgCs16 = NULL, *imgCssource = NULL;
            SDL_Rect positionImg, positionFond, deplacement, positionIni, positionViseur, positionChoix, positionHs, positionOs, positionExit, position10, position20, position50, positionLow, positionMiddle, positionHigh, positionAk, positionScout, positionCs16, positionCssource;
            SDL_Event event, eventChoix, eventConfig;
            int continuer = 1, config = 1, suivre = 1, premier = 1, scoutviseur = 1, ini[10], i = 0, mod = 0, hs = 1, play = 0, choix = 1, jouer = 1, score = 0, section = MENU, tirs = 0, debut = 0, fin = 0, temps = 0;
            long clicX = 0, clicY = 0;
            long coins[4], headshots, niveau, arme, coinbgy, coinhdy, coinhgx, coinbdx, reload = 0, version;
            const long MAXX = LARGEUR - 110, MINX = 0;
            const long MAXY = HAUTEUR - 143, MINY = 0;
            FILE* fichier = NULL;
            char* end;
            char image[10];
           
           
            SDL_Init(SDL_INIT_VIDEO);
           
            SDL_WM_SetIcon(IMG_Load("icone.jpg"), NULL); // Chargement de l'icone
            ecran = SDL_SetVideoMode(LARGEUR, HAUTEUR, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); // Ouverture de la fenêtre
            SDL_WM_SetCaption("Counter Strike Source - HS trainer - By W@Rn3R$hoO†", NULL)// Initialisation du titre
           
            fichier = fopen("config.ini", "r");
            if (fichier != NULL)
            {
                i = 0;
                while (fgets(ini, 100, fichier) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL)
                {
                    switch(i)
                    {
                        case 0:
                        headshots = strtol(ini, &end, 10);
                        break;
                        case 1:
                        niveau = strtol(ini, &end, 10);
                        break;
                        case 2:
                        arme = strtol(ini, &end, 10);
                        break;
                        case 3:
                        version = strtol(ini, &end, 10);
                        break;
                    }
                    i++;
                }
            }
            fclose(fichier);
           
           
            while(jouer)
            {
                switch (section)
                {
                    case MENU:
                   
                   
                   
                   
                    SDL_ShowCursor(SDL_ENABLE);
                   
                    SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
                   
                    imgChoix = IMG_Load("css.jpg");
                    positionChoix.x = 0;
                    positionChoix.y = 0;
                    blit(imgChoix, ecran, &positionChoix);
                   
                    imgChoix = IMG_Load("mods.jpg");
                    positionChoix.x = 815;
                    positionChoix.y = 60;
                    SDL_BlitSurface(imgChoix, NULL, ecran, &positionChoix);
                   
                    imgHs = IMG_Load("hs.jpg");
                    positionHs.x = 795;
                    positionHs.y = 113;
                    SDL_BlitSurface(imgHs, NULL, ecran, &positionHs);
                   
                    imgOs = IMG_Load("os.jpg");
                    positionOs.x = 805;
                    positionOs.y = 150;
                    SDL_BlitSurface(imgOs, NULL, ecran, &positionOs);
                   
                    imgIni = IMG_Load("options.jpg");
                    positionIni.x = 800;
                    positionIni.y = 644;
                    SDL_BlitSurface(imgIni, NULL, ecran, &positionIni);
                   
                    imgExit = IMG_Load("exit.jpg");
                    positionExit.x = 820;
                    positionExit.y = 684;
                    SDL_BlitSurface(imgExit, NULL, ecran, &positionExit);
                    SDL_Flip(ecran);
                   
                    while(choix)
                    {
                        SDL_WaitEvent(&eventChoix);
                       
                        switch(eventChoix.type)
                        {
                            case SDL_QUIT:
                            choix = 0;
                            jouer = 0;
                            break;
                            case SDL_KEYDOWN:
                            switch(eventChoix.key.keysym.sym)
                            {
                                case SDLK_e:
                                choix = 0;
                                jouer = 0;
                               
                                break;
                                case SDLK_n:
                                choix = 0;
                                continuer = 1;
                                score = 0;
                                tirs = 0;
                                debut = SDL_GetTicks();
                                section = JEU;
                                break;
                            }
                            break;
                           
                            case SDL_MOUSEBUTTONDOWN:
                            switch(eventChoix.button.button)
                            {
                                case SDL_BUTTON_LEFT:
                                clicX = eventChoix.motion.x;
                                clicY = eventChoix.motion.y;
                               
                                coins[0] = positionHs.x;
                                coins[1] = positionHs.x + imgHs->w;
                                coins[2] = positionHs.y;
                                coins[3] = positionHs.y + imgHs->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    choix = 0;
                                    continuer = 1;
                                    score = 0;
                                    tirs = 0;
                                    debut = SDL_GetTicks();
                                    section = JEU;
                                    mod = 1;
                                }
                               
                                coins[0] = positionOs.x;
                                coins[1] = positionOs.x + imgOs->w;
                                coins[2] = positionOs.y;
                                coins[3] = positionOs.y + imgOs->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    choix = 0;
                                    continuer = 1;
                                    score = 0;
                                    tirs = 0;
                                    debut = SDL_GetTicks();
                                    section = JEU;
                                    mod = 2;
                                }
                               
                                coins[0] = positionIni.x;
                                coins[1] = positionIni.x + imgIni->w;
                                coins[2] = positionIni.y;
                                coins[3] = positionIni.y + imgIni->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    choix = 0;
                                    config = 1;
                                    section = OPTIONS;
                                }
                               
                                coins[0] = positionExit.x;
                                coins[1] = positionExit.x + imgExit->w;
                                coins[2] = positionExit.y;
                                coins[3] = positionExit.y + imgExit->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    choix = 0;
                                    jouer = 0;
                                }
                                break;
                            }
                            break;
                        }
                       
                    }
                   
                    choix = 1;
                    break;
                   
                    /* Début du jeu */
                   
                    case JEU:
                   
                    img = IMG_Load("ct1.gif");
                   
                    coinhgx = 0.4*(img->w);
                    coinbdx = 0.6*(img->w);
                    coinhdy = 0.08*(img->h);
                    coinbgy = 0.17*(img->h);
                   
                    if(niveau == 2)
                    {
                        coinhgx *= 0.75;
                        coinbdx *= 0.75;
                        coinhdy *= 0.75;
                        coinbgy *= 0.75;
                    }
                    if(niveau == 3)
                    {
                        coinhgx *= 0.5;
                        coinbdx *= 0.5;
                        coinhdy *= 0.5;
                        coinbgy *= 0.5;
                    }
                   
                    fond = SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
                   
                    if(arme == 1)
                    {
                        viseur = IMG_Load("viseur.gif");
                        positionViseur.x = ecran->w / 2 - viseur->w / 2;
                        positionViseur.y = ecran->h / 2 - viseur->h / 2;
                        SDL_BlitSurface(viseur, NULL, ecran, &positionViseur);
                       
                        if(version == 1)
                            imgFond = IMG_Load("ak16.gif");
                        else
                            imgFond = IMG_Load("ak.gif");
                    }
                    else
                    {
                        if(version == 1)
                            imgFond = IMG_Load("scout16.gif");
                        else
                            imgFond = IMG_Load("scout.gif");
                    }
                    positionFond.x = ecran->w - imgFond->w - 1;
                    positionFond.y = ecran->h - imgFond->h - 1;
                    SDL_BlitSurface(imgFond, NULL, ecran, &positionFond);
                   
                   
                   
                   
                    SDL_EnableKeyRepeat(10, VITESSE);
                    SDL_ShowCursor(SDL_DISABLE);
                    srand(time(NULL));
                   
                    hs = 1;
                   
                    while (continuer)
                    {
                        if(hs)
                        {
                            if((arme == 2 && reload <= SDL_GetTicks()) || arme == 1)
                            {
                                positionImg.x = 0;
                                positionImg.y = 0;
                               
                                sprintf(image, "ct%ld.gif", niveau);
                                img = IMG_Load(image);
                                SDL_WarpMouse(ecran->w / 2, ecran->h / 2);
                                positionImg.x = (rand() % (MAXX - MINX + 1)) + MINX;
                                positionImg.y = (rand() % (MAXY - MINY + 1)) + MINY;
                                suivre = 1;
                                hs = 0;
                            }
                           
                        }
                       
                        SDL_WaitEvent(&event);
                       
                       
                       
                        switch(event.type)
                        {
                            case SDL_QUIT:
                            continuer = 0;
                            section = MENU;
                            break;
                            case SDL_KEYDOWN:
                            switch(event.key.keysym.sym)
                            {
                                case SDLK_ESCAPE:
                                continuer = 0;
                                jouer = 0;
                                break;
                                case SDLK_INSERT:
                                SDL_ShowCursor(SDL_ENABLE);
                                break;
                            }
                            break;
                            case SDL_MOUSEMOTION:
                            deplacement.x = positionImg.x + ((ecran->w / 2) - event.motion.x);
                            deplacement.y = positionImg.y + ((ecran->h / 2) - event.motion.y);
                            break;
                            case SDL_MOUSEBUTTONDOWN:
                           
                            switch(event.button.button)
                            {
                                case SDL_BUTTON_LEFT:
                                if((arme == 2 && reload <= SDL_GetTicks()) || arme == 1)
                                {
                                    scoutviseur = 1;
                                    suivre = 1;
                                    if(mod == 2)
                                    {
                                        hs = 1;
                                    }
                                    tirs++;
                                    clicX = event.motion.x;
                                    clicY = event.motion.y;
                                   
                                    if((clicX >= (positionImg.x + coinhgx) && clicX <= (positionImg.x + coinbdx)) && (clicY >= (positionImg.y + coinhdy) && clicY <= (positionImg.y + coinbgy)))
                                    {
                                        hs = 1;
                                        score++;
                                        suivre = 0;
                                        if(score == headshots)
                                        {
                                            continuer = 0;
                                            section = MENU;
                                            fin = SDL_GetTicks();
                                            temps = fin - debut;
                                            fichier = fopen("scores.txt", "a+");
                                            fprintf(fichier, "HS : %ld, Tirs : %ld, Temps : %ld secondes, Score : %ld\n", score, tirs, temps/1000, (score*100)/(tirs)-(temps/1000/2));
                                            fclose(fichier);
                                        }
                                    }
                                    if(arme == 2)
                                    {
                                        reload = SDL_GetTicks()+1000;
                                        premier = 0;
                                        if(version == 1)
                                            imgFond = IMG_Load("scout16.gif");
                                        else
                                            imgFond = IMG_Load("scout.gif");
                                        positionFond.x = ecran->w - imgFond->w - 1;
                                        positionFond.y = ecran->h - imgFond->h - 1;
                                    }
                                }
                                break;
                                case SDL_BUTTON_RIGHT:
                                if(arme == 2)
                                {
                                    if(scoutviseur == 1 && reload <= SDL_GetTicks())
                                    {
                                        if(version == 1)
                                            imgFond = IMG_Load("viseurscout16.gif");
                                        else
                                            imgFond = IMG_Load("viseurscout.gif");
                                        positionFond.x = ecran->w - imgFond->w - 1;
                                        positionFond.y = ecran->h - imgFond->h - 1;
                                        scoutviseur = 0;
                                    }
                                    else
                                    {
                                        if(version == 1)
                                            imgFond = IMG_Load("scout16.gif");
                                        else
                                            imgFond = IMG_Load("scout.gif");
                                        positionFond.x = ecran->w - imgFond->w - 1;
                                        positionFond.y = ecran->h - imgFond->h - 1;
                                        scoutviseur = 1;
                                    }
                                }
                                break;
                            }
                            break;
                           
                           
                        }
                       
                        SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
                       
                        if(continuer == 1)
                        {
                            if(hs && reload <= SDL_GetTicks())
                            {
                                SDL_BlitSurface(img, NULL, ecran, &positionImg);
                            }
                           
                            if(suivre)
                            {
                                SDL_BlitSurface(img, NULL, ecran, &deplacement);
                            }
                           
                            SDL_BlitSurface(imgFond, NULL, ecran, &positionFond);
                            if(arme == 1)
                            {
                                SDL_BlitSurface(viseur, NULL, ecran, &positionViseur);
                            }
                        }
                        SDL_Flip(ecran);
                    }
                   
                   
                   
                    break;
                   
                    case OPTIONS:
                   
                    SDL_ShowCursor(SDL_ENABLE);
                   
                    SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));
                   
                    imgChoix = IMG_Load("ini.jpg");
                    positionChoix.x = 0;
                    positionChoix.y = 0;
                    SDL_BlitSurface(imgChoix, NULL, ecran, &positionChoix);
                   
                    if(headshots != 10)
                    {
                        img10 = IMG_Load("10.jpg");
                    }
                    else
                    {
                        img10 = IMG_Load("10r.jpg");
                    }
                    position10.x = 34;
                    position10.y = 77;
                    SDL_BlitSurface(img10, NULL, ecran, &position10);
                   
                    if(headshots != 20)
                    {
                        img20 = IMG_Load("20.jpg");
                    }
                    else
                    {
                        img20 = IMG_Load("20r.jpg");
                    }
                    position20.x = 34;
                    position20.y = 122;
                    SDL_BlitSurface(img20, NULL, ecran, &position20);
                   
                    if(headshots != 50)
                    {
                        img50 = IMG_Load("50.jpg");
                    }
                    else
                    {
                        img50 = IMG_Load("50r.jpg");
                    }
                    position50.x = 34;
                    position50.y = 167;
                    SDL_BlitSurface(img50, NULL, ecran, &position50);
                   
                    if(niveau != 1)
                    {
                        imgLow = IMG_Load("low.jpg");
                    }
                    else
                    {
                        imgLow = IMG_Load("lowr.jpg");
                    }
                    positionLow.x = 34;
                    positionLow.y = 350;
                    SDL_BlitSurface(imgLow, NULL, ecran, &positionLow);
                   
                    if(niveau != 2)
                    {
                        imgMiddle = IMG_Load("middle.jpg");
                    }
                    else
                    {
                        imgMiddle = IMG_Load("middler.jpg");
                    }
                    positionMiddle.x = 34;
                    positionMiddle.y = 385;
                    SDL_BlitSurface(imgMiddle, NULL, ecran, &positionMiddle);
                   
                    if(niveau != 3)
                    {
                        imgHigh = IMG_Load("high.jpg");
                    }
                    else
                    {
                        imgHigh = IMG_Load("highr.jpg");
                    }
                    positionHigh.x = 34;
                    positionHigh.y = 420;
                    SDL_BlitSurface(imgHigh, NULL, ecran, &positionHigh);
                   
                    if(arme != 1)
                    {
                        imgAk = IMG_Load("w-ak.jpg");
                    }
                    else
                    {
                        imgAk = IMG_Load("w-akr.jpg");
                    }
                    positionAk.x = 34;
                    positionAk.y = 589;
                    SDL_BlitSurface(imgAk, NULL, ecran, &positionAk);
                   
                    if(arme != 2)
                    {
                        imgScout = IMG_Load("w-scout.jpg");
                    }
                    else
                    {
                        imgScout = IMG_Load("w-scoutr.jpg");
                    }
                    positionScout.x = 34;
                    positionScout.y = 624;
                    SDL_BlitSurface(imgScout, NULL, ecran, &positionScout);
                   
                    if(version != 1)
                    {
                        imgCs16 = IMG_Load("cs16.jpg");
                    }
                    else
                    {
                        imgCs16 = IMG_Load("cs16r.jpg");
                    }
                    positionCs16.x = 580;
                    positionCs16.y = 77;
                    SDL_BlitSurface(imgCs16, NULL, ecran, &positionCs16);
                   
                    if(version != 2)
                    {
                        imgCssource = IMG_Load("cssource.jpg");
                    }
                    else
                    {
                        imgCssource = IMG_Load("cssourcer.jpg");
                    }
                    positionCssource.x = 580;
                    positionCssource.y = 115;
                    SDL_BlitSurface(imgCssource, NULL, ecran, &positionCssource);
                   
                    imgExit = IMG_Load("save.jpg");
                    positionExit.x = 831;
                    positionExit.y = 681;
                    SDL_BlitSurface(imgExit, NULL, ecran, &positionExit);
                   
                   
                    SDL_Flip(ecran);
                   
                    while(config)
                    {
                        switch(headshots)
                        {
                            case 10:
                            img10 = IMG_Load("10r.jpg");
                            img20 = IMG_Load("20.jpg");
                            img50 = IMG_Load("50.jpg");
                            break;
                            case 20 :
                            img10 = IMG_Load("10.jpg");
                            img20 = IMG_Load("20r.jpg");
                            img50 = IMG_Load("50.jpg");
                            break;
                            case 50:
                            img10 = IMG_Load("10.jpg");
                            img20 = IMG_Load("20.jpg");
                            img50 = IMG_Load("50r.jpg");
                            break;
                        }
                        switch(niveau)
                        {
                            case 1:
                            imgLow = IMG_Load("lowr.jpg");
                            imgMiddle = IMG_Load("middle.jpg");
                            imgHigh = IMG_Load("high.jpg");
                            break;
                            case 2:
                            imgLow = IMG_Load("low.jpg");
                            imgMiddle = IMG_Load("middler.jpg");
                            imgHigh = IMG_Load("high.jpg");
                            break;
                            case 3:
                            imgLow = IMG_Load("low.jpg");
                            imgMiddle = IMG_Load("middle.jpg");
                            imgHigh = IMG_Load("highr.jpg");
                            break;
                        }
                        switch(arme)
                        {
                            case 1:
                            imgAk = IMG_Load("w-akr.jpg");
                            imgScout = IMG_Load("w-scout.jpg");
                            break;
                            case 2:
                            imgAk = IMG_Load("w-ak.jpg");
                            imgScout = IMG_Load("w-scoutr.jpg");
                            break;
                        }
                        switch(version)
                        {
                            case 1:
                            imgCs16 = IMG_Load("cs16r.jpg");
                            imgCssource = IMG_Load("cssource.jpg");
                            break;
                            case 2:
                            imgCs16 = IMG_Load("cs16.jpg");
                            imgCssource = IMG_Load("cssourcer.jpg");
                            break;
                        }
                       
                        SDL_WaitEvent(&eventConfig);
                       
                        switch(eventConfig.type)
                        {
                            case SDL_QUIT:
                            config = 0;
                            jouer = 0;
                            break;
                            case SDL_KEYDOWN:
                            switch(eventConfig.key.keysym.sym)
                            {
                                case SDLK_s:
                                config = 0;
                                section = MENU;
                                break;
                            }
                            break;
                           
                            case SDL_MOUSEBUTTONDOWN:
                            switch(eventConfig.button.button)
                            {
                                case SDL_BUTTON_LEFT:
                                clicX = eventConfig.motion.x;
                                clicY = eventConfig.motion.y;
                               
                                coins[0] = position10.x;
                                coins[1] = position10.x + img10->w;
                                coins[2] = position10.y;
                                coins[3] = position10.y + img10->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    headshots = 10;
                                }
                               
                                coins[0] = position20.x;
                                coins[1] = position20.x + img20->w;
                                coins[2] = position20.y;
                                coins[3] = position20.y + img20->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    headshots = 20;
                                }
                               
                                coins[0] = position50.x;
                                coins[1] = position50.x + img50->w;
                                coins[2] = position50.y;
                                coins[3] = position50.y + img50->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    headshots = 50;
                                }
                               
                                coins[0] = positionLow.x;
                                coins[1] = positionLow.x + imgLow->w;
                                coins[2] = positionLow.y;
                                coins[3] = positionLow.y + imgLow->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    niveau = 1;
                                }
                               
                                coins[0] = positionMiddle.x;
                                coins[1] = positionMiddle.x + imgMiddle->w;
                                coins[2] = positionMiddle.y;
                                coins[3] = positionMiddle.y + imgMiddle->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    niveau = 2;
                                }
                               
                                coins[0] = positionHigh.x;
                                coins[1] = positionHigh.x + imgHigh->w;
                                coins[2] = positionHigh.y;
                                coins[3] = positionHigh.y + imgHigh->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    niveau = 3;
                                }
                               
                                coins[0] = positionAk.x;
                                coins[1] = positionAk.x + imgAk->w;
                                coins[2] = positionAk.y;
                                coins[3] = positionAk.y + imgAk->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    arme = 1;
                                }
                               
                                coins[0] = positionScout.x;
                                coins[1] = positionScout.x + imgScout->w;
                                coins[2] = positionScout.y;
                                coins[3] = positionScout.y + imgScout->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    arme = 2;
                                }
                               
                                coins[0] = positionCs16.x;
                                coins[1] = positionCs16.x + imgCs16->w;
                                coins[2] = positionCs16.y;
                                coins[3] = positionCs16.y + imgCs16->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    version = 1;
                                }
                               
                                coins[0] = positionCssource.x;
                                coins[1] = positionCssource.x + imgCssource->w;
                                coins[2] = positionCssource.y;
                                coins[3] = positionCssource.y + imgCssource->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    version = 2;
                                }
                               
                                coins[0] = positionExit.x;
                                coins[1] = positionExit.x + imgExit->w;
                                coins[2] = positionExit.y;
                                coins[3] = positionExit.y + imgExit->h;
                               
                                if((clicX >= coins[0] && clicX <= coins[1]) && (clicY >= coins[2] && clicY <= coins[3]))
                                {
                                    config = 0;
                                    section = MENU;
                                    ini[0] = headshots;
                                    ini[1] = niveau;
                                    ini[2] = arme;
                                    ini[3] = version;
                                    fichier = fopen("config.ini", "w+");
                                    fprintf(fichier, "%ld\n%ld\n%ld\n%ld\n", ini[0], ini[1], ini[2], ini[3]);
                                   
                                    fclose(fichier);
                                }
                                break;
                            }
                            break;
                        }
                       
                        SDL_BlitSurface(img10, NULL, ecran, &position10);
                        SDL_BlitSurface(img20, NULL, ecran, &position20);
                        SDL_BlitSurface(img50, NULL, ecran, &position50);
                        SDL_BlitSurface(imgLow, NULL, ecran, &positionLow);
                        SDL_BlitSurface(imgMiddle, NULL, ecran, &positionMiddle);
                        SDL_BlitSurface(imgHigh, NULL, ecran, &positionHigh);
                        SDL_BlitSurface(imgAk, NULL, ecran, &positionAk);
                        SDL_BlitSurface(imgScout, NULL, ecran, &positionScout);
                        SDL_BlitSurface(imgCs16, NULL, ecran, &positionCs16);
                        SDL_BlitSurface(imgCssource, NULL, ecran, &positionCssource);
                        SDL_Flip(ecran);
                       
                    }
                   
                    break;
                   
                }
            }
           
            SDL_FreeSurface(imgFond);
            SDL_FreeSurface(img);
            SDL_FreeSurface(fond);
            SDL_FreeSurface(ecran);
            SDL_FreeSurface(viseur);
            SDL_FreeSurface(imgChoix);
            SDL_FreeSurface(imgHs);
            SDL_FreeSurface(imgOs);
            SDL_FreeSurface(imgExit);
            SDL_FreeSurface(img10);
            SDL_FreeSurface(img20);
            SDL_FreeSurface(img50);
            SDL_FreeSurface(imgIni);
            SDL_FreeSurface(imgScout);
            SDL_FreeSurface(imgAk);
            SDL_FreeSurface(imgCs16);
            SDL_FreeSurface(imgCssource);
            SDL_Quit();
            return EXIT_SUCCESS;
        }




        fonctions.c :

        #include <stdlib.h>
        #include <math.h>
        #include <stdio.h>
        #include <SDL/SDL.h>
        #include <SDL/SDL_image.h>
        #include "prototypes.h"
        #define MENU 1
        #define JEU 2
        #define OPTION 3


        void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect position)
        {

            SDL_BlitSurface(image, NULL, surface, &position);
        }


        C'est long je sais, merci bien :)

        Edit : je vais dormir, je réponderais aux questions demain, merciiiii !
        • Partager sur Facebook
        • Partager sur Twitter
          15 avril 2006 à 0:36:36

          Essaie ceci:

          void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect *position)
          {

              SDL_BlitSurface(image, NULL, surface, &position);
          }

          • Partager sur Facebook
          • Partager sur Twitter
            15 avril 2006 à 2:59:54

            void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect *position)
            {

            SDL_BlitSurface(image, NULL, surface, &position);
            }

            Puisque position est un pointeur il contient l'adresse de la variable donc si tu envoit l'adresse du pointeur et bien ça plante :) donc plustot:


            SDL_BlitSurface(image, NULL, surface, position);

            Sinon ça devrais marcher

            P.S. Essai quand même de corriger les Warning de ton main :p mine de rien un warning peut tout démolir ^^
            • Partager sur Facebook
            • Partager sur Twitter
              15 avril 2006 à 3:12:52

              Citation : Alcor


              Puisque position est un pointeur il contient l'adresse de la variable donc si tu envoit l'adresse du pointeur et bien ça plante :) donc plustot:



              Je me trompe peut-être mais SDL_Rect est une structure, et si tu regarde les cours sur les structures "Envoi de la structure à une fonction":

              Citation : M@teo21

              Bien, et maintenant que nous sommes dans initialiserCoordonnees, nous allons initialiser chacune des valeurs une à une.
              Il ne faut pas oublier de mettre une étoile devant le nom du pointeur pour accéder à la variable. Si vous ne le faites pas, vous risquez de modifier l'adresse, et ce n'est pas ce que nous voulons faire


              • Partager sur Facebook
              • Partager sur Twitter
                15 avril 2006 à 5:51:34

                Pour un code aussi long, je pense qu'il serai interessant d'utiliser la programmation modulaire! :)
                • Partager sur Facebook
                • Partager sur Twitter
                  15 avril 2006 à 7:58:32

                  La programmation quoi ? :lol:

                  Désolé mais aucun de vos code ne compile, si on enlève & devant position, une erreur sit que le 4ème argument n'est pas valide :(
                  • Partager sur Facebook
                  • Partager sur Twitter
                    15 avril 2006 à 9:05:44

                    et en passant x et y en argument, et en refaisant la struct SDL_Rect dans la fonction?
                    C'est ce que je fais et c'est plus simple en plus : pas besoin de déclarer des SDL_Rect a chaque appel de fonction.
                    • Partager sur Facebook
                    • Partager sur Twitter
                      15 avril 2006 à 9:32:11

                      Si tu parles de ça...

                      void blit(SDL_Surface *image, SDL_Surface *surface, long positionX, long positionY)
                      {
                          SDL_Rect position;
                          position.x = positionX;
                          position.y = positionY;

                          SDL_BlitSurface(image, NULL, surface, &position);
                      }


                      ...ça ne marche pas non plus :(:'(:(:'(
                      • Partager sur Facebook
                      • Partager sur Twitter
                      Anonyme
                        15 avril 2006 à 9:39:45

                        Et si tu appelait la fonction ainsi :

                        blit(immage, surface, position);


                        Et dans la fonction :

                        void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect position) {
                            SDL_BlitSurface(image, NULL, surface, &position);
                        }


                        OU BIEN

                        blit(immage, surface, &position);


                        void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect *position) {
                            SDL_BlitSurface(image, NULL, surface, position);
                        }


                        Mais je ne vois pas l'interet de faire une fonction qui remplace SDL_BlitSurface juste parce qu'il y a un argument en plus!


                        • Partager sur Facebook
                        • Partager sur Twitter
                          15 avril 2006 à 9:42:16

                          Citation : W@Rn3R$HoO†



                          #include <stdlib.h>
                          #include <math.h>
                          #include <stdio.h>
                          #include <SDL/SDL.h>
                          #include <SDL/SDL_image.h>
                          #include "prototypes.h"
                          #define MENU 1
                          #define JEU 2
                          #define OPTION 3


                          void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect position)
                          {

                              SDL_BlitSurface(image, NULL, surface, &position);
                          }



                          Le 3eme argument n'est pas un pointeur, alors je vois pas pourquoi:

                          blit(imgChoix, ecran, &positionChoix);

                          le "&" devant positionChoix??????
                          essai ça(avec la fonction de départ):

                          blit(imgChoix,ecran,positionChoix);

                          P.S:
                          le code de la fontion:

                          void blit(SDL_Surface *img, SDL_Surface *surface,SDL_Rect position)
                          {
                               SDL_BlitSurface(img,NULL,surface,&position);
                          }
                          • Partager sur Facebook
                          • Partager sur Twitter
                            15 avril 2006 à 11:16:07

                            Tous ces codes ne fonctionnent pas :(

                            Je veut comprendre les fonctions autres que avec des chiffres et lettres, c'est pas trop pour blitter ;)

                            Edit : Je vais paraître pour un gros boulet, mais codes::block a foiré, il ne compile plus du tout :(

                            Je réessaierais les codes quand cela fonctionnera, désolé :(

                            Le code suivant marche, on s'est donné du mal pour rien avec mes c*****ies :colere: :

                            blit(imgChoix, ecran, positionChoix);


                            void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect position)
                            {
                                SDL_BlitSurface(image, NULL, surface, &position);
                            }


                            Merci encore !
                            • Partager sur Facebook
                            • Partager sur Twitter
                              15 avril 2006 à 11:50:15

                              Citation : W@Rn3R$HoO†

                              Salut à tous, je cherche à faire une fonction blit, mais la compilation echoue :( :
                              <...>
                              Merci infinement de votre aide, j'ai tout essayer :'(



                              Certes, mais as tu refléchi ?

                              Il faut transmettre l'adresse de positionChoix à SDL_blit(). Il faut donc un paramètre du type pointeur sur le bon type.

                              void blit(SDL_Surface *image, SDL_Surface *surface, SDL_Rect *p_position)
                              {
                                  SDL_BlitSurface(image, NULL, surface, p_position);
                              }

                              Appel inchangé :
                              blit(imgChoix, ecran, &positionChoix);

                              • Partager sur Facebook
                              • Partager sur Twitter
                              Music only !
                                15 avril 2006 à 11:55:12

                                Je pouvais toujours réfléchir, le logiciel buggait...
                                • Partager sur Facebook
                                • Partager sur Twitter
                                  15 avril 2006 à 11:56:16

                                  Citation : W@Rn3R$HoO†

                                  Je pouvais toujours réfléchir, le logiciel buggait...


                                  Et maintenant, ça marche ?
                                  • Partager sur Facebook
                                  • Partager sur Twitter
                                  Music only !
                                    15 avril 2006 à 12:25:56

                                    Oui, je crois qu'il y avait des problème "d'interférences" entre mes projets, tous cela est rentré dans l'autre ! Merci :)
                                    • Partager sur Facebook
                                    • Partager sur Twitter

                                    Les fonctions c'est pas mon truc :(

                                    × 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