Partage
  • Partager sur Facebook
  • Partager sur Twitter

Programme qui plante quand je le ferme SDL

Sujet résolu
    19 février 2017 à 23:36:14

    Bonsoir,

    je suis en train de programmer un petit jeux, tout ce passe bien mais quand je clic sur la croix pour fermer la fenêtre, et bien elle ne se ferme pas et le programme crache.

    C'est pas une erreur comme si l'event SDL_Quit était mal codé, non car tout marcher bien.

    Voici mon code qui n'est pas du tout optimisé je sais :

    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <time.h>
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include <SDL/SDL_ttf.h>
    #include <fmod.h>
    
    
    
    
    typedef struct
    {
    	char key[SDLK_LAST];
    	int mousex,mousey;
    	int mousexrel,mouseyrel;
    	char mousebuttons[8];
            char quit;
    } Input;
    
    
    
    void UpdateEvents(Input* in)
    {
    	SDL_Event event;
            in->mousebuttons[SDL_BUTTON_WHEELUP] = 0;
            in->mousebuttons[SDL_BUTTON_WHEELDOWN] = 0;
    	while(SDL_PollEvent(&event))
    	{
    		switch (event.type)
    		{
    		case SDL_KEYDOWN:
    			in->key[event.key.keysym.sym]=1;
    			break;
    		case SDL_KEYUP:
    			in->key[event.key.keysym.sym]=0;
    			break;
    		case SDL_MOUSEMOTION:
    			in->mousex=event.motion.x;
    			in->mousey=event.motion.y;
    			in->mousexrel=event.motion.xrel;
    			in->mouseyrel=event.motion.yrel;
    			break;
    		case SDL_MOUSEBUTTONDOWN:
    			in->mousebuttons[event.button.button]=1;
    			break;
    		case SDL_MOUSEBUTTONUP:
                            if (event.button.button!=SDL_BUTTON_WHEELUP && event.button.button!=SDL_BUTTON_WHEELDOWN)
    			   in->mousebuttons[event.button.button]=0;
    			break;
    		case SDL_QUIT:
    			in->quit = 1;
    			break;
    		default:
    			break;
    		}
    	}
    }
    
    
    
    
    
    
    
    int main ( int argc, char** argv )
    {
    
        SDL_Surface *ecran = NULL;
        SDL_Surface *fond = NULL;
    
        SDL_Surface *cursor[10];
    
        SDL_Surface *slotMenu = NULL;
    
        SDL_Surface *slotMap[7]; // 0 = vide || 1 = coal || 2 = iron || 3 = gold || 4 = diamond || 5 = emerald || 6 = building
        SDL_Surface *slotShop[6]; // 0 = mineral || 1 = tool || 2 = build || 3 = upgrade || 4 = contract || 5 = inventory
        SDL_Surface *slotInfo[8]; // 0 = money || 1 = energy || 2 = stone || 3 = coal || 4 = iron || 5 = gold || 6 = diamond || 7 = emerald
        SDL_Surface *slotMapLock = NULL;
        SDL_Surface *slotMapOk[7]; // 0 = vide || 1 = coal || 2 = iron || 3 = gold || 4 = diamond || 5 = emerald || 6 = building
    
        SDL_Surface *slotQuitMap = NULL;
        SDL_Surface *slotOptionMap = NULL;
        SDL_Surface *slotOptionMapOk = NULL;
        SDL_Surface *slotOptionMapChoice = NULL;
        SDL_Surface *mapTheme[6]; // 0 = vide || 1 = coal || 2 = iron || 3 = gold || 4 = diamond || 5 = emerald
    
        SDL_Surface *mineralOre[6];
    
        SDL_Surface *slotAddContract[3];
        SDL_Surface *slotContract = NULL;
    
        SDL_Surface *slotShopOk[6];
    
        SDL_Surface *slotInventory[24];
        SDL_Surface *slotInventoryOk = NULL;
        SDL_Surface *slotSellOk = NULL;
    
        SDL_Surface *slotSwitchInventory[2];
        SDL_Surface *slotSwitchInventoryOk[2];
    
        SDL_Surface *itemInventory[24];
    
    
    
    
    
        SDL_Surface *textPaper = NULL;
        SDL_Surface *textEnergy = NULL;
        SDL_Surface *textStone = NULL;
        SDL_Surface *textCoal = NULL;
        SDL_Surface *textIron = NULL;
        SDL_Surface *textGold = NULL;
        SDL_Surface *textDiamond = NULL;
        SDL_Surface *textEmerald = NULL;
    
        SDL_Surface *textMaxEnergy = NULL;
        SDL_Surface *textMaxStone = NULL;
        SDL_Surface *textMaxCoal = NULL;
        SDL_Surface *textMaxIron = NULL;
        SDL_Surface *textMaxGold = NULL;
        SDL_Surface *textMaxDiamond = NULL;
        SDL_Surface *textMaxEmerald = NULL;
    
    
    
    
        int i = 0;
        int u = 0;
        int b = 0;
        int a = 0;
    
        SDL_Rect posInit;
        SDL_Rect posSlotMenu;
        SDL_Rect posSlotMap[9];
        SDL_Rect posSlotShop[6];
        SDL_Rect posSlotInfo[8];
        SDL_Rect posSlotQuitMap;
        SDL_Rect posSlotOptionChoice[3];
        SDL_Rect posAddContract;
        SDL_Rect posSlotContract;
        SDL_Rect posMineralOre;
        SDL_Rect posS;
        SDL_Rect posC;
        SDL_Rect posTextInfo[15];
        SDL_Rect posSlotInventory[10];
    
        posInit.x = 0;
        posInit.y = 0;
    
        posSlotMenu.x = 1000;
        posSlotMenu.y = 0;
    
        posSlotMap[0].x = 0;
        posSlotMap[0].y = 0;
        posSlotMap[1].x = 0;
        posSlotMap[1].y = 165;
        posSlotMap[2].x = 0;
        posSlotMap[2].y = 330;
        posSlotMap[3].x = 0;
        posSlotMap[3].y = 495;
        posSlotMap[4].x = 250;
        posSlotMap[4].y = 0;
        posSlotMap[5].x = 250;
        posSlotMap[5].y = 165;
        posSlotMap[6].x = 250;
        posSlotMap[6].y = 330;
        posSlotMap[7].x = 250;
        posSlotMap[7].y = 495;
    
        posSlotShop[0].x = 501;
        posSlotShop[0].y = 0;
        posSlotShop[1].x = 584;
        posSlotShop[1].y = 0;
        posSlotShop[2].x = 667;
        posSlotShop[2].y = 0;
        posSlotShop[3].x = 750;
        posSlotShop[3].y = 0;
        posSlotShop[4].x = 833;
        posSlotShop[4].y = 0;
        posSlotShop[5].x = 916;
        posSlotShop[5].y = 0;
    
        posSlotInfo[0].x = 1000;
        posSlotInfo[0].y = 50;
        posSlotInfo[1].x = 1000;
        posSlotInfo[1].y = 126;
        posSlotInfo[2].x = 1000;
        posSlotInfo[2].y = 202;
        posSlotInfo[3].x = 1000;
        posSlotInfo[3].y = 278;
        posSlotInfo[4].x = 1000;
        posSlotInfo[4].y = 354;
        posSlotInfo[5].x = 1000;
        posSlotInfo[5].y = 430;
        posSlotInfo[6].x = 1000;
        posSlotInfo[6].y = 506;
        posSlotInfo[7].x = 1000;
        posSlotInfo[7].y = 582;
    
        posSlotQuitMap.x = 475;
        posSlotQuitMap.y = 0;
    
        posSlotOptionChoice[0].x = 150;
        posSlotOptionChoice[0].y = 0;
        posSlotOptionChoice[1].x = 150;
        posSlotOptionChoice[1].y = 50;
        posSlotOptionChoice[2].x = 150;
        posSlotOptionChoice[2].y = 100;
    
        posAddContract.x = 300;
        posAddContract.y = 0;
    
        posSlotContract.x = 350;
        posSlotContract.y = 20;
    
        posMineralOre.x = 125;
        posMineralOre.y = 100;
    
        posTextInfo[0].x = 1010;
        posTextInfo[0].y = 55;
        posTextInfo[1].x = 1010;
        posTextInfo[1].y = 131;
        posTextInfo[2].x = 1060;
        posTextInfo[2].y = 165;
        posTextInfo[3].x = 1010;
        posTextInfo[3].y = 207;
        posTextInfo[4].x = 1060;
        posTextInfo[4].y = 241;
        posTextInfo[5].x = 1010;
        posTextInfo[5].y = 283;
        posTextInfo[6].x = 1060;
        posTextInfo[6].y = 317;
        posTextInfo[7].x = 1010;
        posTextInfo[7].y = 359;
        posTextInfo[8].x = 1060;
        posTextInfo[8].y = 393;
        posTextInfo[9].x = 1010;
        posTextInfo[9].y = 435;
        posTextInfo[10].x = 1060;
        posTextInfo[10].y = 469;
        posTextInfo[11].x = 1010;
        posTextInfo[11].y = 511;
        posTextInfo[12].x = 1060;
        posTextInfo[12].y = 545;
        posTextInfo[13].x = 1010;
        posTextInfo[13].y = 587;
        posTextInfo[14].x = 1060;
        posTextInfo[14].y = 621;
    
        posSlotInventory[0].x = 500;
        posSlotInventory[0].y = 80;
        posSlotInventory[1].x = 750;
        posSlotInventory[1].y = 80;
        posSlotInventory[2].x = 500;
        posSlotInventory[2].y = 196;
        posSlotInventory[3].x = 750;
        posSlotInventory[3].y = 196;
        posSlotInventory[4].x = 500;
        posSlotInventory[4].y = 312;
        posSlotInventory[5].x = 750;
        posSlotInventory[5].y = 312;
        posSlotInventory[6].x = 500;
        posSlotInventory[6].y = 428;
        posSlotInventory[7].x = 750;
        posSlotInventory[7].y = 428;
        posSlotInventory[8].x = 500;
        posSlotInventory[8].y = 544;
        posSlotInventory[9].x = 750;
        posSlotInventory[9].y = 544;
    
    
    
    
    
    
    
        SDL_Init(SDL_INIT_VIDEO);
        TTF_Init();
    
        FILE* fichier = NULL;
    
        Input in;
    
    
        TTF_Font *police = NULL;
        SDL_Color couleurNoir = {0, 0, 0};
        police = TTF_OpenFont("police/ariblk.ttf", 20);
    
    
        int terminer = 0;
        int continuer = 0;
        int free = 0; //pour libérer les mémoire
    
        int no = 0;
    
        int mapLock[8];
    
        int slotOkMap[8];
    
        int showMap = 8; // 8 = rien
        int typeMap[8];
    
        int slotMapQuitOk = 0;
        int slotOkOptionMap = 0;
    
        int showOptionChoice = 0;
    
        int showAddContract = 0;
        int slotAddContractOk[2];
    
        int itemMemory = 24;
        int itemMemoryLock = 24;
    
        int addContractType = 24;// 24 = rien
    
        int slotOkShop[6];
        int shopOpen = 6;
    
        int slotItemInventory[24];
        int menuInventory = 0; // 0-1-2
    
        int slotOkInventory[8];
        int slotTradeOk[8];
    
        int inHand = 24; // 24 = nothing
    
        int slotInventorySwitchOk[2];
    
        slotItemInventory[0] = 0;
        slotItemInventory[1] = 0;
        slotItemInventory[2] = 0;
        slotItemInventory[3] = 0;
        slotItemInventory[4] = 0;
        slotItemInventory[5] = 0;
        slotItemInventory[6] = 0;
        slotItemInventory[7] = 0;
        slotItemInventory[8] = 0;
        slotItemInventory[9] = 0;
        slotItemInventory[10] = 0;
        slotItemInventory[11] = 0;
        slotItemInventory[12] = 0;
        slotItemInventory[13] = 0;
        slotItemInventory[14] = 0;
        slotItemInventory[15] = 0;
        slotItemInventory[16] = 0;
        slotItemInventory[17] = 0;
        slotItemInventory[18] = 0;
        slotItemInventory[19] = 0;
        slotItemInventory[20] = 0;
        slotItemInventory[21] = 0;
        slotItemInventory[22] = 0;
        slotItemInventory[23] = 0;
    
    
    
    
    
    
        int paper = 0;
        int energy = 0;
        int stone = 0;
        int coal = 0;
        int iron = 0;
        int gold = 0;
        int diamond = 0;
        int emerald = 0;
    
        int maxEnergy = 0;
        int maxStone = 0;
        int maxCoal = 0;
        int maxIron = 0;
        int maxGold = 0;
        int maxDiamond = 0;
        int maxEmerald = 0;
    
        char charPaper[25] = "";
        char charEnergy[25] = "";
        char charStone[25] = "";
        char charCoal[25] = "";
        char charIron[25] = "";
        char charGold[25] = "";
        char charDiamond[25] = "";
        char charEmerald[25] = "";
    
        char charMaxEnergy[25] = "";
        char charMaxStone[25] = "";
        char charMaxCoal[25] = "";
        char charMaxIron[25] = "";
        char charMaxGold[25] = "";
        char charMaxDiamond[25] = "";
        char charMaxEmerald[25] = "";
    
    
        i = 0;
        while (i != 8)
        {
            mapLock[i] = 1;
            slotOkMap[i] = 0;
            slotOkInventory[i] = 0;
            slotTradeOk[i] = 0;
            typeMap[i] = 0;
            i ++;
        }
        mapLock[0] = 0;
    
        i = 0;
        while (i != 6)
        {
            slotOkShop[i] = 0;
            i ++;
        }
    
        i = 0;
        while (i != 2)
        {
            slotInventorySwitchOk[i] = 0;
            slotAddContractOk[i] = 0;
            i ++;
        }
    
    
    
    
        ecran = SDL_SetVideoMode(1280, 660, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
        SDL_WM_SetCaption("Mineur Clicker", NULL);
    
        SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
    
        fond = IMG_Load("frame/decord/fond.png");
    
        cursor[0] = IMG_Load("frame/cursor/hand.png");
        cursor[1] = IMG_Load("frame/cursor/fist.png");
        cursor[2] = IMG_Load("frame/cursor/hand.png");
        cursor[3] = IMG_Load("frame/cursor/hand.png");
        cursor[4] = IMG_Load("frame/cursor/hand.png");
        cursor[5] = IMG_Load("frame/cursor/hand.png");
        cursor[6] = IMG_Load("frame/cursor/hand.png");
        cursor[7] = IMG_Load("frame/cursor/hand.png");
        cursor[8] = IMG_Load("frame/cursor/hand.png");
        cursor[9] = IMG_Load("frame/cursor/hand.png");
    
        slotMenu = IMG_Load("frame/slotInfo/slotMenu.png");
    
        slotMap[0] = IMG_Load("frame/slotMap/slotVide.png");
        slotMap[1] = IMG_Load("frame/slotMap/slotCoal.png");
        slotMap[2] = IMG_Load("frame/slotMap/slotIron.png");
        slotMap[3] = IMG_Load("frame/slotMap/slotGold.png");
        slotMap[4] = IMG_Load("frame/slotMap/slotDiamond.png");
        slotMap[5] = IMG_Load("frame/slotMap/slotEmerald.png");
    
        slotMapOk[0] = IMG_Load("frame/slotMap/slotVideOk.png");
        slotMapOk[1] = IMG_Load("frame/slotMap/slotCoalOk.png");
        slotMapOk[2] = IMG_Load("frame/slotMap/slotIronOk.png");
        slotMapOk[3] = IMG_Load("frame/slotMap/slotGoldOk.png");
        slotMapOk[4] = IMG_Load("frame/slotMap/slotDiamondOk.png");
        slotMapOk[5] = IMG_Load("frame/slotMap/slotEmeraldOk.png");
    
        slotMapLock = IMG_Load("frame/slotMap/slotMapLock.png");
    
        mapTheme[0] = IMG_Load("frame/map/mapVide.png");
        mapTheme[1] = IMG_Load("frame/map/mapVide.png");
        mapTheme[2] = IMG_Load("frame/map/mapVide.png");
        mapTheme[3] = IMG_Load("frame/map/mapVide.png");
        mapTheme[4] = IMG_Load("frame/map/mapVide.png");
        mapTheme[5] = IMG_Load("frame/map/mapVide.png");
    
        mineralOre[0] = IMG_Load("frame/map/vide.png");
        mineralOre[1] = IMG_Load("frame/map/coalOre.png");
        mineralOre[2] = IMG_Load("frame/map/coalOre.png");
        mineralOre[3] = IMG_Load("frame/map/coalOre.png");
        mineralOre[4] = IMG_Load("frame/map/coalOre.png");
        mineralOre[5] = IMG_Load("frame/map/coalOre.png");
    
        slotQuitMap = IMG_Load("frame/map/slotQuitMap.png");
        slotOptionMap = IMG_Load("frame/map/slotOptionMap.png");
        slotOptionMapOk = IMG_Load("frame/map/slotOptionMapOk.png");
        slotOptionMapChoice = IMG_Load("frame/map/slotOptionMapChoice.png");
    
        slotAddContract[0] = IMG_Load("frame/map/addContract.png");
        slotAddContract[1] = IMG_Load("frame/map/addContractOk.png");
        slotAddContract[2] = IMG_Load("frame/map/addContractPlace.png");
    
        slotContract = IMG_Load("frame/item/contract.png");
    
        slotInfo[0] = IMG_Load("frame/slotInfo/slotPaper.png");
        slotInfo[1] = IMG_Load("frame/slotInfo/slotEnergy.png");
        slotInfo[2] = IMG_Load("frame/slotInfo/slotStone.png");
        slotInfo[3] = IMG_Load("frame/slotInfo/slotCoal.png");
        slotInfo[4] = IMG_Load("frame/slotInfo/slotIron.png");
        slotInfo[5] = IMG_Load("frame/slotInfo/slotGold.png");
        slotInfo[6] = IMG_Load("frame/slotInfo/slotDiamond.png");
        slotInfo[7] = IMG_Load("frame/slotInfo/slotEmerald.png");
    
        slotShop[0] = IMG_Load("frame/slotShop/slotMineral.png");
        slotShop[1] = IMG_Load("frame/slotShop/slotTool.png");
        slotShop[2] = IMG_Load("frame/slotShop/slotBuild.png");
        slotShop[3] = IMG_Load("frame/slotShop/slotUpgrade.png");
        slotShop[4] = IMG_Load("frame/slotShop/slotContract.png");
        slotShop[5] = IMG_Load("frame/slotShop/slotInventory.png");
    
        slotShopOk[0] = IMG_Load("frame/slotShop/slotMineralOk.png");
        slotShopOk[1] = IMG_Load("frame/slotShop/slotToolOk.png");
        slotShopOk[2] = IMG_Load("frame/slotShop/slotBuildOk.png");
        slotShopOk[3] = IMG_Load("frame/slotShop/slotUpgradeOk.png");
        slotShopOk[4] = IMG_Load("frame/slotShop/slotContractOk.png");
        slotShopOk[5] = IMG_Load("frame/slotShop/slotInventoryOk.png");
    
        slotInventory[0] = IMG_Load("frame/slotShop/inventory/nothing.png");
        slotInventory[1] = IMG_Load("frame/slotShop/inventory/coalContract.png");
        slotInventory[2] = IMG_Load("frame/slotShop/inventory/ironContract.png");
        slotInventory[3] = IMG_Load("frame/slotShop/inventory/goldContract.png");
        slotInventory[4] = IMG_Load("frame/slotShop/inventory/diamondContract.png");
        slotInventory[5] = IMG_Load("frame/slotShop/inventory/emeraldContract.png");
        slotInventory[6] = IMG_Load("frame/slotShop/inventory/stoneStorage.png");
        slotInventory[7] = IMG_Load("frame/slotShop/inventory/coalStorage.png");
        slotInventory[8] = IMG_Load("frame/slotShop/inventory/ironStorage.png");
        slotInventory[9] = IMG_Load("frame/slotShop/inventory/goldStorage.png");
        slotInventory[10] = IMG_Load("frame/slotShop/inventory/diamondStorage.png");
        slotInventory[11] = IMG_Load("frame/slotShop/inventory/emeraldStorage.png");
        slotInventory[12] = IMG_Load("frame/slotShop/inventory/energyStorage.png");
        slotInventory[13] = IMG_Load("frame/slotShop/inventory/farmer.png");
        slotInventory[14] = IMG_Load("frame/slotShop/inventory/coalDrill.png");
        slotInventory[15] = IMG_Load("frame/slotShop/inventory/ironDrill.png");
        slotInventory[16] = IMG_Load("frame/slotShop/inventory/goldDrill.png");
        slotInventory[17] = IMG_Load("frame/slotShop/inventory/diamondDrill.png");
        slotInventory[18] = IMG_Load("frame/slotShop/inventory/emeraldDrill.png");
        slotInventory[19] = IMG_Load("frame/slotShop/inventory/furnace.png");
        slotInventory[20] = IMG_Load("frame/slotShop/inventory/coalStation.png");
        slotInventory[21] = IMG_Load("frame/slotShop/inventory/solarPanel.png");
        slotInventory[22] = IMG_Load("frame/slotShop/inventory/windTurbine.png");
        slotInventory[23] = IMG_Load("frame/slotShop/inventory/hydraulicSystem.png");
    
        slotInventoryOk = IMG_Load("frame/slotShop/inventoryOk.png");
        slotSellOk = IMG_Load("frame/slotShop/slotSellOk.png");
    
        slotSwitchInventory[0] = IMG_Load("frame/slotShop/slotSwitchLeft.png");
        slotSwitchInventory[1] = IMG_Load("frame/slotShop/slotSwitchRight.png");
        slotSwitchInventoryOk[0] = IMG_Load("frame/slotShop/slotSwitchLeftOk.png");
        slotSwitchInventoryOk[1] = IMG_Load("frame/slotShop/slotSwitchRightOk.png");
    
        itemInventory[0] = IMG_Load("frame/item/contract.png");
        itemInventory[1] = IMG_Load("frame/item/contract.png");
        itemInventory[2] = IMG_Load("frame/item/contract.png");
        itemInventory[3] = IMG_Load("frame/item/contract.png");
        itemInventory[4] = IMG_Load("frame/item/contract.png");
        itemInventory[5] = IMG_Load("frame/item/contract.png");
        itemInventory[6] = IMG_Load("frame/item/storage.png");
        itemInventory[7] = IMG_Load("frame/item/storage.png");
        itemInventory[8] = IMG_Load("frame/item/storage.png");
        itemInventory[9] = IMG_Load("frame/item/storage.png");
        itemInventory[10] = IMG_Load("frame/item/storage.png");
        itemInventory[11] = IMG_Load("frame/item/storage.png");
        itemInventory[12] = IMG_Load("frame/item/energyStorageItem.png");
        itemInventory[13] = IMG_Load("frame/item/farmerItem.png");
        itemInventory[14] = IMG_Load("frame/item/drill.png");
        itemInventory[15] = IMG_Load("frame/item/drill.png");
        itemInventory[16] = IMG_Load("frame/item/drill.png");
        itemInventory[17] = IMG_Load("frame/item/drill.png");
        itemInventory[18] = IMG_Load("frame/item/drill.png");
        itemInventory[19] = IMG_Load("frame/item/furnaceItem.png");
        itemInventory[20] = IMG_Load("frame/item/coalStationItem.png");
        itemInventory[21] = IMG_Load("frame/item/solarPanel.png");
        itemInventory[22] = IMG_Load("frame/item/windTurbineItem.png");
        itemInventory[23] = IMG_Load("frame/item/hydraulicSystemItem.png");
    
    
    
    
    
    
        //------------------------------------------------------------- DELETE --------------------------------------------------------------
    
        mapLock[1] = 0;
    
        paper = 10000;
        maxStone = 1000;
        maxCoal = 1000;
    
        slotItemInventory[1] = 4;
        slotItemInventory[0] = 1;
        slotItemInventory[11] = 17;
    
    
    
        //------------------------------------------------------------- DELETE --------------------------------------------------------------
        //SDL_ShowCursor(SDL_DISABLE);
    
        memset(&in,0,sizeof(in));
        continuer = 0;
        while (continuer != 1)
        {
    
    
    
    	UpdateEvents(&in);
            if (in.quit)
            {
                continuer = 1;
                terminer = 1;
            }
            if (in.mousebuttons[SDL_BUTTON_LEFT])
            {
                in.mousebuttons[SDL_BUTTON_LEFT] = 0;
    
    
                //------------------------------------------------------------------------------ Map Interact ----------------------------------------------------------------------------------------
                if (showMap != 8)
                {
                    if (slotMapQuitOk == 1)
                    {
                         showMap = 8;
                         showOptionChoice = 0;
                         slotMapQuitOk = 0;
                         showAddContract = 0;
                         addContractType = 24;
                         itemMemoryLock = 24;
                    }
                    if (slotOkOptionMap == 1)
                    {
                        if (showOptionChoice)
                        {
                            showOptionChoice = 0;
                            showAddContract = 0;
                            addContractType = 24;
                            itemMemoryLock = 24;
                        }
                        else
                        {
                            showOptionChoice = 1;
                        }
                    }
                    if (showOptionChoice == 1)
                    {
                        if (slotOkOptionMap == 2)
                        {
                            if (showAddContract)
                            {
                                showAddContract = 0;
                                addContractType = 24;
                                itemMemoryLock = 24;
                            }
                            else
                            {
                                showAddContract = 1;
                                addContractType = 24;
                                itemMemoryLock = 24;
                            }
                        }
                        if (slotOkOptionMap == 3)
                        {
                            typeMap[showMap] = 0;
                            showOptionChoice = 0;
                            showAddContract = 0;
                            addContractType = 24;
                            itemMemoryLock = 24;
                            showMap = 8;
                        }
                    }
                    if (slotAddContractOk[1] == 1)
                    {
                        if (inHand > 4)
                        {
    
                        }
                        else
                        {
                            addContractType = inHand;
                            itemMemoryLock = itemMemory;
                            inHand = 0;
                        }
                    }
                    if (slotAddContractOk[0] == 1)
                    {
                        if (addContractType == 24)
                        {
    
                        }
                        else
                        {
                            showOptionChoice = 0;
                            slotMapQuitOk = 0;
                            showAddContract = 0;
    
    
                            typeMap[showMap] = addContractType;
    
                            slotItemInventory[itemMemoryLock] = 0;
                            itemMemoryLock = 24;
    
                            addContractType = 24;
                            showMap = 8;
                        }
                    }
    
                }
                else
                {
                    i = 0;
                    while (i != 8)
                    {
                        if (slotOkMap[i] == 1)
                        {
                            showMap = i;
                            slotOkMap[i] = 0;
                        }
                        i ++;
                    }
                }
                //------------------------------------------------------------------------------ Map Interact ----------------------------------------------------------------------------------------
    
                //---------------------------------------------------------------------------- Inventory Interact ------------------------------------------------------------------------------------
                if (slotOkShop[0] == 1)
                {
                    shopOpen = 1;
                }
                if (slotOkShop[1] == 1)
                {
                    shopOpen = 2;
                }
                if (slotOkShop[2] == 1)
                {
                    shopOpen = 3;
                }
                if (slotOkShop[3] == 1)
                {
                    shopOpen = 4;
                }
                if (slotOkShop[4] == 1)
                {
                    shopOpen = 5;
                }
                if (slotOkShop[5] == 1)
                {
                    shopOpen = 6;
                }
    
                if (slotInventorySwitchOk[0] == 1)
                {
                    if (menuInventory != 0)
                    {
                        menuInventory --;
                    }
                }
                if (slotInventorySwitchOk[1] == 1)
                {
                    if (menuInventory != 2)
                    {
                        menuInventory ++;
                    }
                }
    
    
                i = 0;
                u = menuInventory * 8;
                while (i != 8)
                {
                    if (slotTradeOk[i] == 1)
                    {
                        if (shopOpen == 6)
                        {
                            u = u + i;
                            if (slotItemInventory[u] == 1)
                            {
                                paper = paper + 10000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 2)
                            {
                                paper = paper + 100000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 3)
                            {
                                paper = paper + 500000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 4)
                            {
                                paper = paper + 1000000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 5)
                            {
                                paper = paper + 2500000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 6)
                            {
                                paper = paper + 100;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 7)
                            {
                                paper = paper + 1000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 8)
                            {
                                paper = paper + 10000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 9)
                            {
                                paper = paper + 100000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 10)
                            {
                                paper = paper + 200000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 11)
                            {
                                paper = paper + 500000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 12)
                            {
                                paper = paper + 15000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 13)
                            {
                                paper = paper + 1000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 14)
                            {
                                paper = paper + 5000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 15)
                            {
                                paper = paper + 50000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 16)
                            {
                                paper = paper + 250000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 17)
                            {
                                paper = paper + 500000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 18)
                            {
                                paper = paper + 1250000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 19)
                            {
                                paper = paper + 15000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 20)
                            {
                                paper = paper + 250000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 21)
                            {
                                paper = paper + 750000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 22)
                            {
                                paper = paper + 350000;
                                slotItemInventory[u] = 0;
                            }
                            if (slotItemInventory[u] == 23)
                            {
                                paper = paper + 500000;
                                slotItemInventory[u] = 0;
                            }
                        }
                        no = 1;
                        inHand = 24;
                        addContractType = 24;
                    }
                    i ++;
                }
    
    
                if (no != 1)
                {
                    if (inHand == 24)
                    {
                        i = 0;
                        u = menuInventory * 8;
                        b = 0;
                        while (i != 8)
                        {
                            b = u + i;
                            if (slotOkInventory[i] == 1)
                            {
                                inHand = slotItemInventory[b];
                                itemMemory = b;
                            }
                            i ++;
                        }
                    }
                    else
                    {
                        inHand = 24;
                    }
                }
    
                no = 0;
    
                //---------------------------------------------------------------------------- Inventory Interact ------------------------------------------------------------------------------------
    
    
            }
    
    
    
    
    
    
            posS.x = in.mousex;
            posS.y = in.mousey;
    
            posC.x = posS.x - 25;
            posC.y = posS.y - 25;
    
    
    
    
    
            SDL_BlitSurface(fond, NULL, ecran, &posInit);
    
    
            //------------------------------------------------------------------------------------ Map -----------------------------------------------------------------------------------------------
            if (showMap == 8)
            {
    
                i = 0;
                b = 0;
                while (i != 8)
                {
                    b = typeMap[i];
                    SDL_BlitSurface(slotMap[b], NULL, ecran, &posSlotMap[i]);
                    i ++;
                }
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotMap[i].x && posS.x <= posSlotMap[i].x + 250 && posS.y >= posSlotMap[i].y && posS.y <= posSlotMap[i].y + 165)
                    {
                        if (mapLock[i] == 0)
                        {
                            slotOkMap[i] = 1;
                            b = typeMap[i];
                            SDL_BlitSurface(slotMapOk[b], NULL, ecran, &posSlotMap[i]);
                        }
    
                    }
                    else
                    {
                        slotOkMap[i] = 0;
                    }
                    i ++;
                }
                i = 0;
                while (i != 8)
                {
                    if (mapLock[i] == 1)
                    {
                        SDL_BlitSurface(slotMapLock, NULL, ecran, &posSlotMap[i]);
                    }
                    i ++;
                }
    
            }
            else
            {
    
                if (posS.x >= posSlotQuitMap.x && posS.x <= posSlotQuitMap.x + 25 && posS.y >= posSlotQuitMap.y && posS.y <= posSlotQuitMap.y + 25)
                {
                    slotMapQuitOk = 1;
                }
                else
                {
                    slotMapQuitOk = 0;
                }
    
    
                SDL_BlitSurface(mapTheme[0], NULL, ecran, &posInit);
    
                i = 0;
                while (i != 5)
                {
                    if (typeMap[showMap] == i)
                    {
                        SDL_BlitSurface(mineralOre[i], NULL, ecran, &posMineralOre);
                    }
                    i ++;
                }
    
    
    
                SDL_BlitSurface(slotOptionMap, NULL, ecran ,&posInit);
                if (showOptionChoice == 1)
                {
                    SDL_BlitSurface(slotOptionMapChoice, NULL, ecran, &posSlotOptionChoice[0]);
                }
                if (posS.x >= posInit.x && posS.x <= posInit.x + 150 && posS.y >= posInit.y && posS.y <= posInit.y + 50)
                {
                    slotOkOptionMap = 1;
                    SDL_BlitSurface(slotOptionMapOk, NULL, ecran, &posInit);
    
                }
                else if (posS.x >= posInit.x + 150 && posS.x <= posInit.x + 300 && posS.y >= posInit.y && posS.y <= posInit.y + 50 && showOptionChoice == 1)
                {
                    slotOkOptionMap = 2;
                    SDL_BlitSurface(slotOptionMapOk, NULL, ecran, &posSlotOptionChoice[0]);
    
                }
                else if (posS.x >= posInit.x + 150 && posS.x <= posInit.x + 300 && posS.y >= posInit.y + 50 && posS.y <= posInit.y + 100 && showOptionChoice == 1)
                {
                    slotOkOptionMap = 3;
                    SDL_BlitSurface(slotOptionMapOk, NULL, ecran, &posSlotOptionChoice[1]);
    
                }
                else if (posS.x >= posInit.x + 150 && posS.x <= posInit.x + 300 && posS.y >= posInit.y + 100 && posS.y <= posInit.y + 150 && showOptionChoice == 1)
                {
                    slotOkOptionMap = 4;
                    SDL_BlitSurface(slotOptionMapOk, NULL, ecran, &posSlotOptionChoice[2]);
    
                }
                else
                {
                    slotOkOptionMap = 0;
                }
    
                if (showAddContract == 1)
                {
                    SDL_BlitSurface(slotAddContract[0], NULL, ecran, &posAddContract);
                }
    
                if (posS.x >= posAddContract.x + 47 && posS.x <= posAddContract.x + 102 && posS.y >= posAddContract.y + 87 && posS.y <= posAddContract.y + 116 && showOptionChoice == 1 && showAddContract == 1)
                {
                    slotAddContractOk[0] = 1;
                    SDL_BlitSurface(slotAddContract[1], NULL, ecran, &posAddContract);
                }
                else
                {
                    slotAddContractOk[0] = 0;
                }
                if (posS.x >= posAddContract.x + 50 && posS.x <= posAddContract.x + 99 && posS.y >= posAddContract.y + 21 && posS.y <= posAddContract.y + 70 && showOptionChoice == 1 && showAddContract == 1)
                {
                    slotAddContractOk[1] = 1;
                    SDL_BlitSurface(slotAddContract[2], NULL, ecran, &posAddContract);
                }
                else
                {
                    slotAddContractOk[1] = 0;
                }
    
                if (addContractType != 24)
                {
                    SDL_BlitSurface(slotContract, NULL, ecran, &posSlotContract);
                }
    
    
    
    
                SDL_BlitSurface(slotQuitMap, NULL, ecran ,&posSlotQuitMap);
    
            }
            //------------------------------------------------------------------------------------ Map -----------------------------------------------------------------------------------------------
    
    
    
            //------------------------------------------------------------------------------------ Shop ----------------------------------------------------------------------------------------------
            i = 0;
            while (i != 6)
            {
                SDL_BlitSurface(slotShop[i], NULL, ecran, &posSlotShop[i]);
                i ++;
            }
            i = 0;
            while (i != 6)
            {
                if (posS.x >= posSlotShop[i].x && posS.x <= posSlotShop[i].x + 83 && posS.y >= posSlotShop[i].y && posS.y <= posSlotShop[i].y + 80)
                {
                    slotOkShop[i] = 1;
                    SDL_BlitSurface(slotShopOk[i], NULL, ecran, &posSlotShop[i]);
                }
                else
                {
                    slotOkShop[i] = 0;
                }
                i ++;
            }
            if (shopOpen == 1)
            {
    
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
            }
            if (shopOpen == 2)
            {
    
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
            }
            if (shopOpen == 3)
            {
    
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
            }
            if (shopOpen == 4)
            {
    
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
            }
            if (shopOpen == 5)
            {
    
                i = 0;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
            }
            if (shopOpen == 6)
            {
                i = menuInventory * 8;
                u = 0;
                b = 0;
                a = i + 8;
                while (i != a)
                {
                    u = slotItemInventory[i];
                    SDL_BlitSurface(slotInventory[u], NULL, ecran, &posSlotInventory[b]);
                    b ++;
                    i ++;
                }
    
                i = 0;
                u = menuInventory * 8;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x + 20 && posS.x <= posSlotInventory[i].x + 72 && posS.y >= posSlotInventory[i].y + 70 && posS.y <= posSlotInventory[i].y + 102 && slotItemInventory[u] != 0)
                    {
                        slotTradeOk[i] = 1;
                        SDL_BlitSurface(slotSellOk, NULL, ecran, &posSlotInventory[i]);
                        no = 1;
                    }
                    else
                    {
                        slotTradeOk[i] = 0;
                    }
                    i ++;
                    u ++;
                }
    
                if (no == 0)
                {
    
                i = 0;
                b = menuInventory * 8;
                while (i != 8)
                {
                    if (posS.x >= posSlotInventory[i].x && posS.x <= posSlotInventory[i].x + 250 && posS.y >= posSlotInventory[i].y && posS.y <= posSlotInventory[i].y + 116 && slotItemInventory[b] != 0)
                    {
                        slotOkInventory[i] = 1;
                        SDL_BlitSurface(slotInventoryOk, NULL, ecran, &posSlotInventory[i]);
                    }
                    else
                    {
                        slotOkInventory[i] = 0;
                    }
                    i ++;
                    b ++;
                }
                }
                SDL_BlitSurface(slotSwitchInventory[0], NULL, ecran, &posSlotInventory[8]);
                SDL_BlitSurface(slotSwitchInventory[1], NULL, ecran, &posSlotInventory[9]);
                if (posS.x >= posSlotInventory[8].x && posS.x <= posSlotInventory[8].x + 250 && posS.y >= posSlotInventory[8].y && posS.y <= posSlotInventory[8].y + 116)
                {
                    slotInventorySwitchOk[0] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[0], NULL, ecran, &posSlotInventory[8]);
                }
                else
                {
                    slotInventorySwitchOk[0] = 0;
                }
                if (posS.x >= posSlotInventory[9].x && posS.x <= posSlotInventory[9].x + 250 && posS.y >= posSlotInventory[9].y && posS.y <= posSlotInventory[9].y + 116)
                {
                    slotInventorySwitchOk[1] = 1;
                    SDL_BlitSurface(slotSwitchInventoryOk[1], NULL, ecran, &posSlotInventory[9]);
                }
                else
                {
                    slotInventorySwitchOk[1] = 0;
                }
    
    
                no = 0;
            }
            //------------------------------------------------------------------------------------ Shop ----------------------------------------------------------------------------------------------
    
    
    
            //------------------------------------------------------------------------------------ Info ----------------------------------------------------------------------------------------------
            i = 0;
            while (i != 8)
            {
                SDL_BlitSurface(slotInfo[i], NULL, ecran, &posSlotInfo[i]);
                i ++;
            }
    
            sprintf(charPaper, "%d", paper);
            sprintf(charEnergy, "%d", energy);
            sprintf(charMaxEnergy, "/%d", maxEnergy);
            sprintf(charStone, "%d", stone);
            sprintf(charMaxStone, "/%d",maxStone);
            sprintf(charCoal, "%d", coal);
            sprintf(charMaxCoal, "/%d", maxCoal);
            sprintf(charIron, "%d", iron);
            sprintf(charMaxIron, "/%d", maxIron);
            sprintf(charGold, "%d", gold);
            sprintf(charMaxGold, "/%d", maxGold);
            sprintf(charDiamond, "%d", diamond);
            sprintf(charMaxDiamond, "/%d", maxDiamond);
            sprintf(charEmerald, "%d", emerald);
            sprintf(charMaxEmerald, "/%d", maxEmerald);
    
            textPaper = TTF_RenderText_Blended(police, charPaper, couleurNoir);
            textEnergy = TTF_RenderText_Blended(police, charEnergy, couleurNoir);
            textMaxEnergy = TTF_RenderText_Blended(police, charMaxEnergy, couleurNoir);
            textStone = TTF_RenderText_Blended(police, charStone, couleurNoir);
            textMaxStone = TTF_RenderText_Blended(police, charMaxStone, couleurNoir);
            textCoal = TTF_RenderText_Blended(police, charCoal, couleurNoir);
            textMaxCoal = TTF_RenderText_Blended(police, charMaxCoal, couleurNoir);
            textIron = TTF_RenderText_Blended(police, charIron, couleurNoir);
            textMaxIron = TTF_RenderText_Blended(police, charMaxIron, couleurNoir);
            textGold = TTF_RenderText_Blended(police, charGold, couleurNoir);
            textMaxGold = TTF_RenderText_Blended(police, charMaxGold, couleurNoir);
            textDiamond = TTF_RenderText_Blended(police, charDiamond, couleurNoir);
            textMaxDiamond = TTF_RenderText_Blended(police, charMaxDiamond, couleurNoir);
            textEmerald = TTF_RenderText_Blended(police, charEmerald, couleurNoir);
            textMaxEmerald = TTF_RenderText_Blended(police, charMaxEmerald, couleurNoir);
    
            SDL_BlitSurface(textPaper, NULL, ecran, &posTextInfo[0]);
            SDL_BlitSurface(textEnergy, NULL, ecran, &posTextInfo[1]);
            SDL_BlitSurface(textMaxEnergy, NULL, ecran, &posTextInfo[2]);
            SDL_BlitSurface(textStone, NULL, ecran, &posTextInfo[3]);
            SDL_BlitSurface(textMaxStone, NULL, ecran, &posTextInfo[4]);
            SDL_BlitSurface(textCoal, NULL, ecran, &posTextInfo[5]);
            SDL_BlitSurface(textMaxCoal, NULL, ecran, &posTextInfo[6]);
            SDL_BlitSurface(textIron, NULL, ecran, &posTextInfo[7]);
            SDL_BlitSurface(textMaxIron, NULL, ecran, &posTextInfo[8]);
            SDL_BlitSurface(textGold, NULL, ecran, &posTextInfo[9]);
            SDL_BlitSurface(textMaxGold, NULL, ecran, &posTextInfo[10]);
            SDL_BlitSurface(textDiamond, NULL, ecran, &posTextInfo[11]);
            SDL_BlitSurface(textMaxDiamond, NULL, ecran, &posTextInfo[12]);
            SDL_BlitSurface(textEmerald, NULL, ecran, &posTextInfo[13]);
            SDL_BlitSurface(textMaxEmerald, NULL, ecran, &posTextInfo[14]);
    
            SDL_FreeSurface(textPaper);
            SDL_FreeSurface(textEnergy);
            SDL_FreeSurface(textStone);
            SDL_FreeSurface(textCoal);
            SDL_FreeSurface(textIron);
            SDL_FreeSurface(textGold);
            SDL_FreeSurface(textDiamond);
            SDL_FreeSurface(textEmerald);
            SDL_FreeSurface(textMaxEnergy);
            SDL_FreeSurface(textMaxStone);
            SDL_FreeSurface(textMaxCoal);
            SDL_FreeSurface(textMaxIron);
            SDL_FreeSurface(textMaxGold);
            SDL_FreeSurface(textMaxDiamond);
            SDL_FreeSurface(textMaxEmerald);
            //------------------------------------------------------------------------------------ Info ----------------------------------------------------------------------------------------------
    
    
            SDL_BlitSurface(slotMenu, NULL, ecran, &posSlotMenu);
    
    
    
            if (inHand != 24)
            {
                SDL_BlitSurface(itemInventory[inHand], NULL, ecran, &posC);
                //SDL_BlitSurface(cursor[1], NULL, ecran, &posC);
            }
            else
            {
                //SDL_BlitSurface(cursor[0], NULL, ecran, &posC);
            }
    
    
    
    
    
    
    
            SDL_Flip(ecran);
        }
    
    
    
    
        TTF_CloseFont(police);
        TTF_Quit();
    
    
        free = 0;
        while (free != 24)
        {
            SDL_FreeSurface(itemInventory[free]);
            SDL_FreeSurface(slotInventory[free]);
    
        }
        free = 0;
        while (free != 10)
        {
            SDL_FreeSurface(cursor[free]);
        }
        free = 0;
        while (free != 8)
        {
            SDL_FreeSurface(slotInfo[free]);
        }
        free = 0;
        while (free != 7)
        {
            SDL_FreeSurface(slotMap[free]);
            SDL_FreeSurface(slotMapOk[free]);
        }
        free = 0;
        while (free != 6)
        {
            SDL_FreeSurface(mapTheme[free]);
            SDL_FreeSurface(slotShop[free]);
            SDL_FreeSurface(slotShopOk[free]);
            SDL_FreeSurface(mineralOre[free]);
        }
        free = 0;
        while (free != 3)
        {
            SDL_FreeSurface(slotAddContract[free]);
        }
        free = 0;
        while (free != 2)
        {
            SDL_FreeSurface(slotSwitchInventory[free]);
            SDL_FreeSurface(slotSwitchInventoryOk[free]);
        }
    
    
        SDL_FreeSurface(slotContract);
        SDL_FreeSurface(slotSellOk);
        SDL_FreeSurface(slotInventoryOk);
        SDL_FreeSurface(slotOptionMapOk);
        SDL_FreeSurface(slotOptionMapChoice);
        SDL_FreeSurface(slotOptionMap);
        SDL_FreeSurface(slotQuitMap);
        SDL_FreeSurface(slotMapLock);
        SDL_FreeSurface(slotMenu);
        SDL_FreeSurface(fond);
        SDL_Quit();
    
    
        EXIT_SUCCESS;
    }
    

    Merci de bien vouloir m'aider.

    • Partager sur Facebook
    • Partager sur Twitter
    Ne pas se décourager !
      20 février 2017 à 8:02:39

      Commence par organiser ton code correctement. Ton main fait 1400 lignes alors que tu ne contrôles aucun retour de fonction, il devrait en faire 40 à tout casser. C'est un problème largement plus grave que ton plantage actuellement ...

      • Partager sur Facebook
      • Partager sur Twitter

      Posez vos questions ou discutez informatique, sur le Discord NaN | Tuto : Preuve de programmes C

        20 février 2017 à 10:26:39

        Daccord ce n'est pas la premier fois que l'on me fait la remarque alors je vais commencer a crée des fonctions, mais je ne suis pas très doué avec celle si alors voici ce que j'ai commencer à coder, c'est une fonction pour afficher les textes de mon jeu mais quand je lance le jeu les texte ne s'affiche pas. Pourrais tu m'aider ?

        void afficheTextInfo (SDL_Surface* ecran, int *paper, int *energy, int *stone, int *coal, int *iron, int *gold, int *diamond, int *emerald, int *maxEnergy, int *maxStone, int *maxCoal, int *maxIron, int *maxGold, int *maxDiamond, int *maxEmerald)
        {
            SDL_Surface *textPaper = NULL;
            SDL_Surface *textEnergy = NULL;
            SDL_Surface *textStone = NULL;
            SDL_Surface *textCoal = NULL;
            SDL_Surface *textIron = NULL;
            SDL_Surface *textGold = NULL;
            SDL_Surface *textDiamond = NULL;
            SDL_Surface *textEmerald = NULL;
        
            SDL_Surface *textMaxEnergy = NULL;
            SDL_Surface *textMaxStone = NULL;
            SDL_Surface *textMaxCoal = NULL;
            SDL_Surface *textMaxIron = NULL;
            SDL_Surface *textMaxGold = NULL;
            SDL_Surface *textMaxDiamond = NULL;
            SDL_Surface *textMaxEmerald = NULL;
        
            SDL_Rect posTextInfo[15];
        
            posTextInfo[0].x = 1010;
            posTextInfo[0].y = 55;
            posTextInfo[1].x = 1010;
            posTextInfo[1].y = 131;
            posTextInfo[2].x = 1060;
            posTextInfo[2].y = 165;
            posTextInfo[3].x = 1010;
            posTextInfo[3].y = 207;
            posTextInfo[4].x = 1060;
            posTextInfo[4].y = 241;
            posTextInfo[5].x = 1010;
            posTextInfo[5].y = 283;
            posTextInfo[6].x = 1060;
            posTextInfo[6].y = 317;
            posTextInfo[7].x = 1010;
            posTextInfo[7].y = 359;
            posTextInfo[8].x = 1060;
            posTextInfo[8].y = 393;
            posTextInfo[9].x = 1010;
            posTextInfo[9].y = 435;
            posTextInfo[10].x = 1060;
            posTextInfo[10].y = 469;
            posTextInfo[11].x = 1010;
            posTextInfo[11].y = 511;
            posTextInfo[12].x = 1060;
            posTextInfo[12].y = 545;
            posTextInfo[13].x = 1010;
            posTextInfo[13].y = 587;
            posTextInfo[14].x = 1060;
            posTextInfo[14].y = 621;
        
            TTF_Font *police = NULL;
            SDL_Color couleurNoir = {0, 0, 0};
            police = TTF_OpenFont("police/ariblk.ttf", 20);
        
            char charPaper[25] = "";
            char charEnergy[25] = "";
            char charStone[25] = "";
            char charCoal[25] = "";
            char charIron[25] = "";
            char charGold[25] = "";
            char charDiamond[25] = "";
            char charEmerald[25] = "";
        
            char charMaxEnergy[25] = "";
            char charMaxStone[25] = "";
            char charMaxCoal[25] = "";
            char charMaxIron[25] = "";
            char charMaxGold[25] = "";
            char charMaxDiamond[25] = "";
            char charMaxEmerald[25] = "";
        
            sprintf(charPaper, "%d", paper);
            sprintf(charEnergy, "%d", energy);
            sprintf(charMaxEnergy, "/%d", maxEnergy);
            sprintf(charStone, "%d", stone);
            sprintf(charMaxStone, "/%d",maxStone);
            sprintf(charCoal, "%d", coal);
            sprintf(charMaxCoal, "/%d", maxCoal);
            sprintf(charIron, "%d", iron);
            sprintf(charMaxIron, "/%d", maxIron);
            sprintf(charGold, "%d", gold);
            sprintf(charMaxGold, "/%d", maxGold);
            sprintf(charDiamond, "%d", diamond);
            sprintf(charMaxDiamond, "/%d", maxDiamond);
            sprintf(charEmerald, "%d", emerald);
            sprintf(charMaxEmerald, "/%d", maxEmerald);
        
            textPaper = TTF_RenderText_Blended(police, charPaper, couleurNoir);
            textEnergy = TTF_RenderText_Blended(police, charEnergy, couleurNoir);
            textMaxEnergy = TTF_RenderText_Blended(police, charMaxEnergy, couleurNoir);
            textStone = TTF_RenderText_Blended(police, charStone, couleurNoir);
            textMaxStone = TTF_RenderText_Blended(police, charMaxStone, couleurNoir);
            textCoal = TTF_RenderText_Blended(police, charCoal, couleurNoir);
            textMaxCoal = TTF_RenderText_Blended(police, charMaxCoal, couleurNoir);
            textIron = TTF_RenderText_Blended(police, charIron, couleurNoir);
            textMaxIron = TTF_RenderText_Blended(police, charMaxIron, couleurNoir);
            textGold = TTF_RenderText_Blended(police, charGold, couleurNoir);
            textMaxGold = TTF_RenderText_Blended(police, charMaxGold, couleurNoir);
            textDiamond = TTF_RenderText_Blended(police, charDiamond, couleurNoir);
            textMaxDiamond = TTF_RenderText_Blended(police, charMaxDiamond, couleurNoir);
            textEmerald = TTF_RenderText_Blended(police, charEmerald, couleurNoir);
            textMaxEmerald = TTF_RenderText_Blended(police, charMaxEmerald, couleurNoir);
        
            SDL_BlitSurface(textPaper, NULL, ecran, &posTextInfo[0]);
            SDL_BlitSurface(textEnergy, NULL, ecran, &posTextInfo[1]);
            SDL_BlitSurface(textMaxEnergy, NULL, ecran, &posTextInfo[2]);
            SDL_BlitSurface(textStone, NULL, ecran, &posTextInfo[3]);
            SDL_BlitSurface(textMaxStone, NULL, ecran, &posTextInfo[4]);
            SDL_BlitSurface(textCoal, NULL, ecran, &posTextInfo[5]);
            SDL_BlitSurface(textMaxCoal, NULL, ecran, &posTextInfo[6]);
            SDL_BlitSurface(textIron, NULL, ecran, &posTextInfo[7]);
            SDL_BlitSurface(textMaxIron, NULL, ecran, &posTextInfo[8]);
            SDL_BlitSurface(textGold, NULL, ecran, &posTextInfo[9]);
            SDL_BlitSurface(textMaxGold, NULL, ecran, &posTextInfo[10]);
            SDL_BlitSurface(textDiamond, NULL, ecran, &posTextInfo[11]);
            SDL_BlitSurface(textMaxDiamond, NULL, ecran, &posTextInfo[12]);
            SDL_BlitSurface(textEmerald, NULL, ecran, &posTextInfo[13]);
            SDL_BlitSurface(textMaxEmerald, NULL, ecran, &posTextInfo[14]);
        
            SDL_FreeSurface(textPaper);
            SDL_FreeSurface(textEnergy);
            SDL_FreeSurface(textStone);
            SDL_FreeSurface(textCoal);
            SDL_FreeSurface(textIron);
            SDL_FreeSurface(textGold);
            SDL_FreeSurface(textDiamond);
            SDL_FreeSurface(textEmerald);
            SDL_FreeSurface(textMaxEnergy);
            SDL_FreeSurface(textMaxStone);
            SDL_FreeSurface(textMaxCoal);
            SDL_FreeSurface(textMaxIron);
            SDL_FreeSurface(textMaxGold);
            SDL_FreeSurface(textMaxDiamond);
            SDL_FreeSurface(textMaxEmerald);
        
            TTF_CloseFont(police);
            TTF_Quit();
        
            EXIT_SUCCESS;
        }

        Quand j'appelle la fonction :

                afficheTextInfo(ecran, &paper, &energy, &stone, &coal, &iron, &gold, &diamond, &emerald, &maxEnergy, &maxStone, &maxCoal, &maxIron, &maxGold, &maxDiamond, &maxEmerald);
        

        Merci !

        -
        Edité par Sachajoub 20 février 2017 à 10:27:24

        • Partager sur Facebook
        • Partager sur Twitter
        Ne pas se décourager !
          20 février 2017 à 11:03:16

          Tu ne découpes pas assez ta réflexion sur ton programme, ce qui me fait dire que tu n'es pas encore tout à fait prêt pour des programmes plus gros. Regarde par exemple, ici tu as une notion de texte, et plutôt que te donner les moyens de manipuler facilement du texte avec que fonctionnalités ciblées, tu gardes tout mélangé. Alors que l'on peut faire quand même bien plus simple !

          int afficheInfo(int info, int max_info, SDL_Surface* ecran, TTF_Font* police, SDL_Color couleur, int x, int y){
            assert(ecran  && "Pointeur NULL pour ecran");
            assert(police && "Pointeur NULL pour police");
          
            char info_texte[25] = "";
            sprintf(info_texte, "%d/%d", info, max_info);
          
            SDL_Surface surf = TTF_RenderText_Blended(police, info_texte, couleur);
            if(! surf) return 1;
          
            SDL_Rect r;
            r.x = x;
            r.y = y;
          
            SDL_BlitSurface(info_texte, NULL, ecran, &r);
            SDL_FreeSurface(info_texte);
          
            return 0;
          }

          Là, on a une fonction pour afficher une information en texte à une position donnée. Et comment ça transforme le code ?

          int afficheTextInfo (SDL_Surface* ecran, int paper, int energy, int stone, int coal, int iron, int gold, int diamond, int emerald, int maxEnergy, int maxStone, int maxCoal, int maxIron, int maxGold, int maxDiamond, int maxEmerald)
          {
              TTF_Font *police = TTF_OpenFont("police/ariblk.ttf", 20);
              if(! police) return 1;
          
              SDL_Color couleur = {0, 0, 0};
          
              //il faut ajouter les contrôles
              afficheInfo(paper  , maxPaper  , ecran, police, couleur, 1010, 55);
              afficheInfo(erergy , maxEnergy , ecran, police, couleur, 1010, 131);
              afficheInfo(stone  , mapStone  , ecran, police, couleur, 1010, 207);
              afficheInfo(coal   , mapCoal   , ecran, police, couleur, 1010, 283);
              afficheInfo(iron   , mapIron   , ecran, police, couleur, 1010, 359);
              afficheInfo(diamond, mapDiamond, ecran, police, couleur, 1010, 435);
              afficheInfo(emerald, mapEmerald, ecran, police, couleur, 1010, 511);
           
              return 0;
          }

          Il fait la même chose en 100 lignes de moins, et encore : j'ai même ajouté des contrôles d'erreur que tu n'as pas (mais qui sont nécessaires). Et même ce code là, on peut encore lui reproche pleins de trucs :

          • l'entrée de la fonction n'est pas pratique, on aimerait bien avoir des structures pour nos données,
          • les positions sont des valeurs magiques dans le code, on voudrait les configurer (et ça pourrait aussi être mis dans une structure),
          • etc ...

          Bref, avant de code bille en tête. Prends ton problème global et découpe le en idées plus simples. Ensuite, tu reprends ces idées simples et tu recommences, et puis encore, et puis encode. Jusqu'à que les idées soit suffisamment simples pour ne plus pouvoir être découpées. Chacune de ces phases de découpent vont définir les fonctions qu'il va falloir que tu implémentes, mais également les structures de données qui vont rassembler les informations qui vont ensembles, etc.

          Et tant que ton projet n'est pas clairement organisé et posé sur papier, tu n'écris pas une ligne de code, sinon tu cours droit au massacre.

          -
          Edité par Ksass`Peuk 20 février 2017 à 11:49:35

          • Partager sur Facebook
          • Partager sur Twitter

          Posez vos questions ou discutez informatique, sur le Discord NaN | Tuto : Preuve de programmes C

            20 février 2017 à 12:32:53

            Merci beaucoup pour tes conseil je les est appliqués voila le résultat :

            int textInfo (SDL_Surface* ecran, int info, int infoMax, TTF_Font *police, SDL_Color couleurNoir, int x, int y, int xM, int yM)
            {
                SDL_Surface *text = NULL;
                SDL_Surface *textMax = NULL;
            
                SDL_Rect pos;
                SDL_Rect posM;
                pos.x = x;
                pos.y = y;
                posM.x = xM;
                posM.y = yM;
            
                char charText[25] = "";
                char charTextMax[25] = "";
            
                sprintf(charText, "%d", info);
                sprintf(charTextMax, "%d", infoMax);
            
                text = TTF_RenderText_Blended(police, charText, couleurNoir);
                textMax = TTF_RenderText_Blended(police, charText, couleurNoir);
            
                SDL_BlitSurface(text, NULL, ecran, &pos);
                SDL_BlitSurface(textMax, NULL, ecran, &posM);
            
                SDL_FreeSurface(text);
                SDL_FreeSurface(textMax);
            
                return 0;
            }



            Et pour appeler la fonction :

            int afficheTextInfo (SDL_Surface* ecran, int *paper, int *energy, int *stone, int *coal, int *iron, int *gold, int *diamond, int *emerald, int *maxEnergy, int *maxStone, int *maxCoal, int *maxIron, int *maxGold, int *maxDiamond, int *maxEmerald)
            {
                TTF_Font *police = NULL;
                SDL_Color couleurNoir = {0, 0, 0};
                police = TTF_OpenFont("police/ariblk.ttf", 20);
            
                textInfo(ecran, energy, maxEnergy, police, couleurNoir, 1010, 131, 1060, 165);
                textInfo(ecran, stone, maxStone, police, couleurNoir, 1010, 207, 1060, 241);
                textInfo(ecran, coal, maxCoal, police, couleurNoir, 1010, 283, 1060, 317);
                textInfo(ecran, iron, maxIron, police, couleurNoir, 1010, 359, 1060, 393);
                textInfo(ecran, gold, maxGold, police, couleurNoir, 1010, 435, 1060, 469);
                textInfo(ecran, diamond, maxDiamond, police, couleurNoir, 1010, 511, 1060, 545);
                textInfo(ecran, emerald, maxEmerald, police, couleurNoir, 1010, 587, 1060, 621);
            
                TTF_CloseFont(police);
                TTF_Quit();
            
                return 0;
            }



            Et l’appelle de l’appelle de la fonction :

            afficheTextInfo(ecran, &paper, &energy, &stone, &coal, &iron, &gold, &diamond, &emerald, &maxEnergy, &maxStone, &maxCoal, &maxIron, &maxGold, &maxDiamond, &maxEmerald);

            Mais quand je fait ça le programme ne marche pas et j'ai l'erreur suivante :

            error: invalid conversion from 'int*' to 'int'

            Merci de m'aider.

            -
            Edité par Sachajoub 20 février 2017 à 12:45:36

            • Partager sur Facebook
            • Partager sur Twitter
            Ne pas se décourager !
              20 février 2017 à 14:58:21

              Vérifie le prototype de ta fonction.

              EDIT: J'ai lu un peu vite ^^, il faut que tu écrive le nombre pointé et pas le pointeur lui-même.

              Modifie toutes les utilisations des pointeurs en leur ajoutant une étoile (*)

              Par exemple : Remplace paper par *paper dans le corps de ta fonction.

              -
              Edité par TSnake41 20 février 2017 à 15:05:35

              • Partager sur Facebook
              • Partager sur Twitter
                20 février 2017 à 15:00:59

                Déjà fait et je ne voie aucune erreur ...

                EDIT: après je débute c'est ma premier fonction.

                -
                Edité par Sachajoub 20 février 2017 à 15:01:21

                • Partager sur Facebook
                • Partager sur Twitter
                Ne pas se décourager !
                  20 février 2017 à 15:24:08

                  Sachajoub a écrit:

                  EDIT: après je débute c'est ma premier fonction.

                  Alors ce serait pas mal d'attaquer ton apprentissage de C dans le bon ordre. A savoir commencer par apprendre les bases, notamment comment structurer son code, et ensuite s'attaquer à un projet plus conséquent avec SDL. Tu ne peux pas bricoler des trucs quasiment au hasard et espérer que ça va marcher.

                  • Partager sur Facebook
                  • Partager sur Twitter

                  Posez vos questions ou discutez informatique, sur le Discord NaN | Tuto : Preuve de programmes C

                    20 février 2017 à 15:28:26

                    Je connais déjà les bases du C j'ai fini le tuto de @Mateo mais j'ai zappé la partie sur les fonctions ...

                    EDIT : j'ai réussi a réparer mon erreur et le programme se lance mais par contre les textes ne s'affiche toujours pas.

                    Voici le code :

                    int textInfo (SDL_Surface* ecran, int info, int infoMax, TTF_Font *police, SDL_Color couleurNoir, int x, int y, int xM, int yM)
                    {
                        SDL_Surface *text = NULL;
                        SDL_Surface *textMax = NULL;
                    
                        SDL_Rect pos;
                        SDL_Rect posM;
                        pos.x = x;
                        pos.y = y;
                        posM.x = xM;
                        posM.y = yM;
                    
                        char charText[25] = "";
                        char charTextMax[25] = "";
                    
                        sprintf(charText, "%d", info);
                        sprintf(charTextMax, "%d", infoMax);
                    
                        text = TTF_RenderText_Blended(police, charText, couleurNoir);
                        textMax = TTF_RenderText_Blended(police, charText, couleurNoir);
                    
                        SDL_BlitSurface(text, NULL, ecran, &pos);
                        SDL_BlitSurface(textMax, NULL, ecran, &posM);
                    
                        SDL_FreeSurface(text);
                        SDL_FreeSurface(textMax);
                    
                        return 0;
                    }
                    
                    
                    int afficheTextInfo (SDL_Surface* ecran, int paper, int energy, int stone, int coal, int iron, int gold, int diamond, int emerald, int maxEnergy, int maxStone, int maxCoal, int maxIron, int maxGold, int maxDiamond, int maxEmerald)
                    {
                        TTF_Font *police = NULL;
                        SDL_Color couleurNoir = {0, 0, 0};
                        police = TTF_OpenFont("police/ariblk.ttf", 20);
                    
                        textInfo(ecran, energy, maxEnergy, police, couleurNoir, 1010, 131, 1060, 165);
                        textInfo(ecran, stone, maxStone, police, couleurNoir, 1010, 207, 1060, 241);
                        textInfo(ecran, coal, maxCoal, police, couleurNoir, 1010, 283, 1060, 317);
                        textInfo(ecran, iron, maxIron, police, couleurNoir, 1010, 359, 1060, 393);
                        textInfo(ecran, gold, maxGold, police, couleurNoir, 1010, 435, 1060, 469);
                        textInfo(ecran, diamond, maxDiamond, police, couleurNoir, 1010, 511, 1060, 545);
                        textInfo(ecran, emerald, maxEmerald, police, couleurNoir, 1010, 587, 1060, 621);
                    
                        TTF_CloseFont(police);
                        TTF_Quit();
                    
                        return 0;
                    }
                            afficheTextInfo(ecran, paper, energy, stone, coal, iron, gold, diamond, emerald, maxEnergy, maxStone, maxCoal, maxIron, maxGold, maxDiamond, maxEmerald);
                    

                    Merci


                    -
                    Edité par Sachajoub 20 février 2017 à 15:34:41

                    • Partager sur Facebook
                    • Partager sur Twitter
                    Ne pas se décourager !
                      20 février 2017 à 15:34:48

                      Je connais déjà les bases du C j'ai fini le tuto de @Mateo mais j'ai zappé la partie sur les fonctions ...

                      Le tutoriel de Mateo ne donne pas toutes les bases du C, et si en plus tu as sauté la partie sur les fonctions, non tu n’es pas prêt à te lancer dans la création d’un gros programme. Passé la cinquantaine de ligne, l’utilisation de fonctions devrait être obligatoire.

                      -
                      Edité par yo@n97one 20 février 2017 à 15:49:19

                      • Partager sur Facebook
                      • Partager sur Twitter
                      Tutoriel Ruby - Bon tutoriel C - Tutoriel SDL 2 - Python avancé - Faîtes un zeste, devenez des zesteurs
                        20 février 2017 à 15:35:55

                        Sachajoub a écrit:

                        mais j'ai zappé la partie sur les fonctions ...

                        Je vois même pas comment c'est possible ...

                        Comment tu veux développer quoi que ce soit de correct si tu n'as pas pris l'habitude de faire des fonctions en permanence ? Sans parler de la notion de structure qui est également vitale dans ce langage ?

                        Sachajoub a écrit:

                        EDIT : j'ai réussi a réparer mon erreur est le programme ce lance mais par contre les textes ne s'affiche toujours pas.

                        C'est un pansement sur une jambe de bois. Sans compter le fait que tu as viré les contrôles d'erreur (ce qui est suicidaire en C). Rêve pas, tu ne pourras pas coder un truc en C, si tu ne fais pas l'effort de prendre le temps de penser ton programme correctement et si tu n'es pas hyper rigoureux dans la manière dont tu développes avec.

                        Ksass`Peuk a écrit:

                        Et tant que ton projet n'est pas clairement organisé et posé sur papier, tu n'écris pas une ligne de code, sinon tu cours droit au massacre.

                        -
                        Edité par Ksass`Peuk 20 février 2017 à 15:37:42

                        • Partager sur Facebook
                        • Partager sur Twitter

                        Posez vos questions ou discutez informatique, sur le Discord NaN | Tuto : Preuve de programmes C

                          20 février 2017 à 18:31:34

                          Je remarque que ce sujet devient hors sujet ^^ alors je vais le mettre en résolue.

                          Si mon programme planté c'était à cause des boucles final.

                          Avant :

                          free = 0;
                              while (free != 24)
                              {
                                  SDL_FreeSurface(itemInventory[free]);
                                  SDL_FreeSurface(slotInventory[free]);
                           
                              }
                              free = 0;
                              while (free != 10)
                              {
                                  SDL_FreeSurface(cursor[free]);
                              }
                              free = 0;
                              while (free != 8)
                              {
                                  SDL_FreeSurface(slotInfo[free]);
                              }
                              free = 0;
                              while (free != 7)
                              {
                                  SDL_FreeSurface(slotMap[free]);
                                  SDL_FreeSurface(slotMapOk[free]);
                              }
                              free = 0;
                              while (free != 6)
                              {
                                  SDL_FreeSurface(mapTheme[free]);
                                  SDL_FreeSurface(slotShop[free]);
                                  SDL_FreeSurface(slotShopOk[free]);
                                  SDL_FreeSurface(mineralOre[free]);
                              }
                              free = 0;
                              while (free != 3)
                              {
                                  SDL_FreeSurface(slotAddContract[free]);
                              }
                              free = 0;
                              while (free != 2)
                              {
                                  SDL_FreeSurface(slotSwitchInventory[free]);
                                  SDL_FreeSurface(slotSwitchInventoryOk[free]);
                              }

                          Aprés :

                          free = 0;
                              while (free != 24)
                              {
                                  SDL_FreeSurface(itemInventory[free]);
                                  SDL_FreeSurface(slotInventory[free]);
                                  free ++;
                           
                              }
                              free = 0;
                              while (free != 10)
                              {
                                  SDL_FreeSurface(cursor[free]);
                                  free ++;
                              }
                              free = 0;
                              while (free != 8)
                              {
                                  SDL_FreeSurface(slotInfo[free]);
                                  free ++;
                              }
                              free = 0;
                              while (free != 7)
                              {
                                  SDL_FreeSurface(slotMap[free]);
                                  SDL_FreeSurface(slotMapOk[free]);
                                  free ++;
                              }
                              free = 0;
                              while (free != 6)
                              {
                                  SDL_FreeSurface(mapTheme[free]);
                                  SDL_FreeSurface(slotShop[free]);
                                  SDL_FreeSurface(slotShopOk[free]);
                                  SDL_FreeSurface(mineralOre[free]);
                                  free ++;
                              }
                              free = 0;
                              while (free != 3)
                              {
                                  SDL_FreeSurface(slotAddContract[free]);
                                  free ++;
                              }
                              free = 0;
                              while (free != 2)
                              {
                                  SDL_FreeSurface(slotSwitchInventory[free]);
                                  SDL_FreeSurface(slotSwitchInventoryOk[free]);
                                  free ++;
                              }

                          Merci beaucoup

                          -
                          Edité par Sachajoub 21 février 2017 à 9:27:54

                          • Partager sur Facebook
                          • Partager sur Twitter
                          Ne pas se décourager !
                            23 février 2017 à 9:35:57

                            Sachajoub a écrit:

                            Si mon programme planté c'était à cause des boucles final.

                            Ton programme plante parce que tu ne veux pas apprendre à écrire correctement en langage C avant d'entamer un projet complexe.

                            • Partager sur Facebook
                            • Partager sur Twitter

                            Posez vos questions ou discutez informatique, sur le Discord NaN | Tuto : Preuve de programmes C

                              23 février 2017 à 16:14:09

                              J'ai appris tout les cours de mateo je ne voie pas ce que je peut faire de plus ^^

                              D’ailleur voila mon main maintenant :

                              int main ( int argc, char** argv )
                              {
                              
                                  SDL_Surface *ecran = NULL;
                                  SDL_Surface *fond = NULL;
                              
                                  SDL_Rect posInit;
                                  SDL_Rect posS;
                                  SDL_Rect posC;
                              
                                  posInit.x = 0;
                                  posInit.y = 0;
                              
                                  SDL_Init(SDL_INIT_VIDEO);
                                  TTF_Init();
                              
                                  FILE* fichier = NULL;
                              
                                  int terminer = 0;
                                  int continuer = 0;
                                  int i = 0;
                              
                                  int paper = 0;
                                  int energy = 0;
                                  int stone = 0;
                                  int coal = 0;
                                  int iron = 0;
                                  int gold = 0;
                                  int diamond = 0;
                                  int emerald = 0;
                              
                                  int maxEnergy = 0;
                                  int maxStone = 0;
                                  int maxCoal = 0;
                                  int maxIron = 0;
                                  int maxGold = 0;
                                  int maxDiamond = 0;
                                  int maxEmerald = 0;
                              
                                  // -------------- info --------------
                                  int slotMenuOk = 0;
                              
                                  // -------------- map ---------------
                                  int mapLock[8];
                                  int typeMap[8];
                                  int slotOkMap[8];
                                  int slotOkMapLock[8];
                              
                                  // -------------- shop ---------------
                                  int slotOkShop[6];
                                  int shopOpen = 6;
                                  int slotOkInventory[8];
                                  int slotTradeOk[8];
                                  int slotInventorySwitchOk[2];
                              
                                  int slotItemInventory[24];
                                  int menuInventory = 0;
                              
                                  int inHand = 24;
                              
                                  int showMap = 8;
                                  int slotMapQuitOk = 0;
                                  int slotOkOptionMap = 0;
                                  int showOptionChoice = 0;
                              
                                  int showAddContract = 0;
                                  int slotAddContractOk[2];
                                  int addContractType = 24;
                              
                                  int itemMemory = 24;
                                  int itemMemoryLock = 24;
                              
                                  i = 0;
                                  while (i != 2)
                                  {
                                      slotInventorySwitchOk[i] = 0;
                                      slotAddContractOk[i] = 0;
                                      i ++;
                                  }
                                  i = 0;
                                  while (i != 6)
                                  {
                                      slotOkShop[i] = 0;
                                      i ++;
                                  }
                                  i = 0;
                                  while (i != 8)
                                  {
                                      mapLock[i] = 1;
                                      slotOkMap[i] = 0;
                                      slotOkInventory[i] = 0;
                                      slotTradeOk[i] = 0;
                                      typeMap[i] = 0;
                                      i ++;
                                  }
                                  mapLock[0] = 0;
                                  i = 0;
                                  while (i != 24)
                                  {
                                      slotItemInventory[i] = 0;
                                      i ++;
                                  }
                              
                                  int Sx = 0;
                                  int Sy = 0;
                                  int Cx = 0;
                                  int Cy = 0;
                              
                                  ecran = SDL_SetVideoMode(1280, 660, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
                                  SDL_WM_SetCaption("Mineur Clicker", NULL);
                                  SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
                              
                                  fond = IMG_Load("frame/decord/fond.png");
                              
                                  //------------------------------------------------------------- DELETE --------------------------------------------------------------
                              
                                  mapLock[1] = 0;
                              
                                  paper = 10000;
                                  coal = 10;
                                  maxStone = 1000;
                                  maxCoal = 1000;
                              
                                  slotItemInventory[1] = 4;
                                  slotItemInventory[0] = 1;
                                  slotItemInventory[11] = 17;
                              
                                  //------------------------------------------------------------- DELETE --------------------------------------------------------------
                                  //SDL_ShowCursor(SDL_DISABLE);
                              
                                  continuer = 0;
                                  while (continuer != 1)
                                  {
                                      Sx = posS.x;
                                      Sy = posS.y;
                                      Cx = posC.x;
                                      Cy = posC.y;
                                      interaction(ecran, &typeMap, &slotAddContractOk, &slotItemInventory, &slotOkMap, &continuer, &addContractType, &showAddContract, &slotMapQuitOk, &showOptionChoice, &showMap, &menuInventory, &shopOpen, &itemMemory, &itemMemoryLock, &paper, &inHand, slotTradeOk, slotInventorySwitchOk, slotOkShop, slotOkInventory, slotOkOptionMap, &Sx, &Sy, &Cx, &Cy);
                                      posS.x = Sx;
                                      posS.y = Sy;
                                      posC.x = Cx;
                                      posC.y = Cy;
                              
                                      SDL_BlitSurface(fond, NULL, ecran, &posInit);
                              
                                      //------------------------------------------------------------------------------------ Map -----------------------------------------------------------------------------------------------
                                      if (showMap == 8)
                                      {
                                          afficheSlotMap(ecran, &slotOkMap, &slotOkMapLock, mapLock, typeMap, posS.x, posS.y);
                                      }
                                      else
                                      {
                                          afficheMap(ecran, &slotMapQuitOk, &slotOkOptionMap, &slotAddContractOk, showOptionChoice, showAddContract, addContractType, showMap, typeMap, posS.x, posS.y);
                                      }
                                      //------------------------------------------------------------------------------------ Map -----------------------------------------------------------------------------------------------
                              
                                      //------------------------------------------------------------------------------------ Shop ----------------------------------------------------------------------------------------------
                                      afficheslotShop(ecran, &slotOkShop, posS.x, posS.y);
                              
                                      if (shopOpen == 1)
                                      {
                              
                                      }
                                      if (shopOpen == 2)
                                      {
                              
                                      }
                                      if (shopOpen == 3)
                                      {
                              
                                      }
                                      if (shopOpen == 4)
                                      {
                              
                              
                                      }
                                      if (shopOpen == 5)
                                      {
                              
                              
                                      }
                                      if (shopOpen == 6)
                                      {
                                          afficheSlotShop6(ecran, &slotOkInventory, &slotTradeOk, slotItemInventory, menuInventory, posS.x, posS.y);
                                      }
                              
                                      afficheSlotSwitch(ecran, &slotInventorySwitchOk, posS.x, posS.y);
                                      //------------------------------------------------------------------------------------ Shop ----------------------------------------------------------------------------------------------
                              
                                      //------------------------------------------------------------------------------------ Info ----------------------------------------------------------------------------------------------
                                      afficheSlotInfo(ecran);
                              
                                      afficheTextInfo(ecran, paper, energy, stone, coal, iron, gold, diamond, emerald, maxEnergy, maxStone, maxCoal, maxIron, maxGold, maxDiamond, maxEmerald);
                              
                                      afficheSlotMenu(ecran, &slotMenuOk, posS.x, posS.y);
                                      //------------------------------------------------------------------------------------ Info ----------------------------------------------------------------------------------------------
                                      afficheCursor(ecran, inHand, posC.x, posC.y);
                              
                                      SDL_Flip(ecran);
                                  }
                              
                                  TTF_Quit();
                              
                                  SDL_FreeSurface(fond);
                                  SDL_Quit();
                              
                                  EXIT_SUCCESS;
                              }
                              



                              • Partager sur Facebook
                              • Partager sur Twitter
                              Ne pas se décourager !
                                23 février 2017 à 16:37:40

                                • Ton main est toujours trop long.
                                • Une fonction, ça devrait être maximum 5 paramètres.
                                • Ta variable terminer ne sert à rien, tu as une variabkle continuer.
                                • Tu ne vérifies pas le retour des fonctions à risques.
                                • Choisis l’anglais ou le français, mais pas les deux ni le franglais.
                                • Partager sur Facebook
                                • Partager sur Twitter
                                Tutoriel Ruby - Bon tutoriel C - Tutoriel SDL 2 - Python avancé - Faîtes un zeste, devenez des zesteurs
                                  23 février 2017 à 17:40:20

                                  Je suis en train de rétrécir mon main en faisant des structures pour mais int ce qui vas aussi alléger mais paramètre de fonction. Et exact pour terminer je n'avais pas vue, et pour la vérif des fonctions a risque c'est prévue. Mais chaque choses en son temps ^^
                                  • Partager sur Facebook
                                  • Partager sur Twitter
                                  Ne pas se décourager !

                                  Programme qui plante quand je le ferme SDL

                                  × 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