示例#1
0
HRESULT App_ExecuteArgList (
   LPCTSTR   aArgs[],
   UINT      ixFirst,  // first arg to execute
   UINT      cArgs)    // count of args to execute
{
   // turn the tokenized arg list into a HCMDLIST of commands.
   //
   HCMDLIST  hlstCmds = NULL;
   HRESULT hr = App_CookArgList (&hlstCmds, aArgs, ixFirst, cArgs);
   if (FAILED(hr) || ! hlstCmds)
      return hr;

   // execute the HCMDLIST
   //
   hr = App_ExecuteCmds(hlstCmds);

   // and now free the HCMDLIST
   //
   Vector_Delete (hlstCmds);

   return hr;
}
示例#2
0
void Inputs_ApplyInputsLevelEditor(Controls* controls,
                            World* world, Window* level_editor,
                            GameManager* gm)
{
    rotate_timer += delta_g;

    if(pressedKeys[SDLK_F1] && SDL_GetTicks() - switch_timer > 200)
    {
        draw_grid_g = draw_grid_g? false : true;
    }

    if(pressedKeys[SDLK_F7] && SDL_GetTicks() - switch_timer > 2000)
    {
        switch_timer = SDL_GetTicks();
        LevelEditor_QuickTry(world);
    }


    int position_in_array = controls->mouseTileY * world->map_width + controls->mouseTileX;

    if(controls->temp_object_to_create != NULL)
    {
        if(pressedKeys[SDLK_f] && !previousPressedKeys_g[SDLK_f])
        {
            SDL_WarpMouseInWindow(Graphics_GetWindow(),
                                  (controls->mouseTileX * TILE_SIZE - world->player.playerC->cameraX),
                                  controls->mouseTileY * TILE_SIZE - world->player.playerC->cameraY);
        }
        if(pressedKeys[SDLK_RIGHT] && !previousPressedKeys_g[SDLK_RIGHT])
        {
            SDL_WarpMouseInWindow(Graphics_GetWindow(),
                                  (controls->mouseX + 1 ),
                                  controls->mouseY);
        }
        if(pressedKeys[SDLK_LEFT] && !previousPressedKeys_g[SDLK_LEFT])
        {
            SDL_WarpMouseInWindow(Graphics_GetWindow(),
                                  (controls->mouseX - 1 ),
                                  controls->mouseY);
        }
        if(pressedKeys[SDLK_UP] && !previousPressedKeys_g[SDLK_UP])
        {
            SDL_WarpMouseInWindow(Graphics_GetWindow(),
                                  (controls->mouseX ),
                                  controls->mouseY - 1);
        }
        if(pressedKeys[SDLK_DOWN] && !previousPressedKeys_g[SDLK_DOWN])
        {
            SDL_WarpMouseInWindow(Graphics_GetWindow(),
                                  (controls->mouseX),
                                  controls->mouseY + 1);
        }

        if(controls->mouseWheelPos < 0 && rotate_timer > 50)
        {
            if(controls->temp_object_to_create->angle == 0)
            {
                controls->temp_object_to_create->angle = HALF_PI;
            }
            else if(controls->temp_object_to_create->angle <= HALF_PI + 0.1f)
            {
                controls->temp_object_to_create->angle = HALF_PI * 2;
            }
            else if(controls->temp_object_to_create->angle <= HALF_PI * 2 + 0.1f)
            {
                controls->temp_object_to_create->angle = HALF_PI * 3;
            }
            else if(controls->temp_object_to_create->angle <= HALF_PI * 3 + 0.1f)
            {
                controls->temp_object_to_create->angle = 0;
            }

            rotate_timer = 0;
        }
        if(controls->mouseWheelPos > 0 && rotate_timer > 50)
        {
            if(controls->temp_object_to_create->angle == 0)
            {
                controls->temp_object_to_create->angle = HALF_PI * 3;
            }
            else if(controls->temp_object_to_create->angle >= HALF_PI * 3 - 0.1f)
            {
                controls->temp_object_to_create->angle = HALF_PI * 2;
            }
            else if(controls->temp_object_to_create->angle >= HALF_PI * 2 - 0.1f)
            {
                controls->temp_object_to_create->angle = HALF_PI;
            }
            else if(controls->temp_object_to_create->angle >= HALF_PI - 0.2f)
            {
                controls->temp_object_to_create->angle = 0;
            }
            rotate_timer = 0;
        }

        controls->temp_object_to_create->x = controls->mousePositionInWorldX;
        controls->temp_object_to_create->y = controls->mousePositionInWorldY;
        BoundingBox_Update(controls->temp_object_to_create);


    }


    Vector* monsters_vector = &world->monsters_vector;
    if(BoundingBox_CheckPointCollision(controls->mouseX, controls->mouseY, &level_editor->box))
    {
       controls->hovering_on_window = true;

        //selecting button in level_editor
        if(controls->pressedMouseButtons[SDL_BUTTON_LEFT])
        {
            for(int i = 0 ; i < level_editor->nb_of_buttons ; i++)
            {
                if(BoundingBox_CheckPointCollision(controls->mouseX,
                                                   controls->mouseY,
                                                   &level_editor->buttons[i].box))
                {
                    level_editor->active_button = &level_editor->buttons[i];

                    if(controls->temp_object_to_create != NULL)
                    {
                        Entity_Destroy(controls->temp_object_to_create);
                        free(controls->temp_object_to_create);
                    }


                    controls->temp_object_to_create = Entity_Create(level_editor->active_button->main_category,
                                                                    level_editor->active_button->button_type,
                                                                    controls->mouseX, controls->mouseY,
                                                                    0, world);



                }
            }
        }

        //showing window resizing cursor
        if((controls->mouseX > level_editor->box.right - 10 ||
           controls->mouseX < level_editor->box.left + 10) &&
           controls->active_window == NULL)
        {
            controls->cursor_resize_left_right = true;

            if(controls->pressedMouseButtons[SDL_BUTTON_LEFT] &&
               controls->previousPressedMouseButtons[SDL_BUTTON_LEFT] &&
               controls->mouseX > level_editor->box.right - 10)
            {
                controls->resizing_right = true;
            }

            if(controls->pressedMouseButtons[SDL_BUTTON_LEFT] &&
               controls->previousPressedMouseButtons[SDL_BUTTON_LEFT] &&
               controls->mouseX < level_editor->box.left + 10)
            {
                controls->resizing_left = true;
            }
        }
        else
        {
            controls->cursor_resize_left_right = false;
        }

        //clicking on the level editor window
       if(controls->pressedMouseButtons[SDL_BUTTON_LEFT] &&
            controls->previousPressedMouseButtons[SDL_BUTTON_LEFT] &&
            !controls->cursor_resize_left_right)
        {
            controls->active_window = level_editor;
        }
    }
    else //if not hovering on the window
    {
        controls->cursor_resize_left_right = false;
        controls->cursor_resize_up_down = false;
        controls->hovering_on_window = false;

    }

    //if you've clicked on the window and then stopped clicking, it's not "active" anymore
    if(controls->active_window != NULL &&
       !controls->previousPressedMouseButtons[SDL_BUTTON_LEFT])
    {
        controls->active_window = NULL;
    }

    //resizing window
    if(controls->resizing_right || controls->resizing_left)
    {
        controls->cursor_resize_left_right = true;

        if(!controls->pressedMouseButtons[SDL_BUTTON_LEFT] &&
           !controls->previousPressedMouseButtons[SDL_BUTTON_LEFT])
        {
            controls->resizing_right = false;
            controls->resizing_left = false;
        }

        if(controls->resizing_right)
        {
            Window_ResizeRight(level_editor, controls->mouseX - controls->previousMouseX);
        }
        else if(controls->resizing_left)
        {
            Window_ResizeLeft(level_editor, controls->mouseX - controls->previousMouseX);
        }

    }

    //moving window
    if(controls->active_window != NULL &&
       controls->pressedMouseButtons[SDL_BUTTON_LEFT] &&
       controls->previousPressedMouseButtons[SDL_BUTTON_LEFT] &&
       !controls->resizing_left && !controls->resizing_right)
    {

         Window_Move(level_editor,
                     controls->mouseX - controls->previousMouseX,
                     controls->mouseY - controls->previousMouseY);
    }

    if(pressedKeys[SDLK_LCTRL])
    {
        unlimited_creation = true;
    }
    else
    {
        unlimited_creation = false;
    }


    //if not hovering and not moving window
    //we can create/delete stuff on the map
    if(!controls->active_window && !controls->hovering_on_window)
    {
        if (level_editor->active_button != NULL)
        {

            Main_Category category = level_editor->active_button->main_category;
            int obj_type = level_editor->active_button->button_type;

            if(!rectangle_selection_create &&
               (controls->pressedMouseButtons[SDL_BUTTON_RIGHT] ||
                pressedKeys[SDLK_SPACE]))
            {
                if (controls->mouseTileX < world->map_width && controls->mouseTileX > 0 &&
                    controls->mouseTileY < world->map_height && controls->mouseTileY > 0)
                {

                    //pressing shift activate the rectangle selection tool
                    if((category == Cat_Wall || category == Cat_Ground) &&
                       pressedKeys[SDLK_LSHIFT])
                    {

                        rectangle_selection_startX = controls->mousePositionInWorldX;
                        rectangle_selection_startY = controls->mousePositionInWorldY;
                        rectangle_selection_create = true;
                    }

                        LevelEditor_CreateObject(category, obj_type, controls->tileInPixelsX, controls->tileInPixelsY,
                                                 position_in_array, controls->mousePositionInWorldX,
                                                 controls->mousePositionInWorldY, world, unlimited_creation,
                                                 controls->temp_object_to_create->angle);

                }
                else
                    printf("out of bound!!!");
            }

            //remove wall (replace it with empty entity)
            if(pressedKeys[SDLK_c])

            {


            }

            //deleting monster
            if(pressedKeys[SDLK_x])
            {
                if(pressedKeys[SDLK_LSHIFT] && !rectangle_selection_delete)
                {
                    rectangle_selection_startX = controls->mousePositionInWorldX;
                    rectangle_selection_startY = controls->mousePositionInWorldY;
                    rectangle_selection_delete = true;
                }
                if(!rectangle_selection_delete)
                {
                    LevelEditor_UpdateWallsCorners(position_in_array, world);
                    free(world->map[position_in_array]);
                    world->map[position_in_array] = NULL;
                }

                for(int i = 0 ; i < Vector_Count(&world->monsters_vector) ; i++)
                {
                    Entity* mob = (Entity*)Vector_Get(&world->monsters_vector, i);
                    if(BoundingBox_CheckPointCollision(controls->mousePositionInWorldX,
                                                       controls->mousePositionInWorldY,
                                                       &mob->box))
                    {
                        Entity_Destroy(mob);
                        Vector_Delete(&world->monsters_vector, i);

                    }
                }
                for(int i = 0 ; i < Vector_Count(&world->bonus_vector) ; i++)
                {
                    Entity* bonus = (Entity*)Vector_Get(&world->bonus_vector, i);
                    if(BoundingBox_CheckPointCollision(controls->mousePositionInWorldX,
                                                       controls->mousePositionInWorldY,
                                                       &bonus->box))
                    {
                        Entity_Destroy(bonus);
                        Vector_Delete(&world->bonus_vector, i);

                    }
                }
                for(int i = 0 ; i < Vector_Count(&world->props_vector) ; i++)
                {
                    Entity* obj = (Entity*)Vector_Get(&world->props_vector, i);
                    if(BoundingBox_CheckPointCollision(controls->mousePositionInWorldX,
                                                       controls->mousePositionInWorldY,
                                                       &obj->box))
                    {
                        Entity_Destroy(obj);
                        Vector_Delete(&world->props_vector, i);

                    }
                }
                for(int i = 0 ; i < Vector_Count(&world->decals_vector) ; i++)
                {
                    Entity* obj = (Entity*)Vector_Get(&world->decals_vector, i);
                    if(BoundingBox_CheckPointCollision(controls->mousePositionInWorldX,
                                                       controls->mousePositionInWorldY,
                                                       &obj->box))
                    {
                        Entity_Destroy(obj);
                        Vector_Delete(&world->decals_vector, i);

                    }
                }
            }



            /*stopping pressing left shift stop the selection and creates the selection tile
            in the selection (only if it's a tile and not a monster/object
            */
            if((rectangle_selection_create || rectangle_selection_delete) && pressedKeys[SDLK_LSHIFT])
            {
                rectangle_selection_endX = controls->mousePositionInWorldX;
                rectangle_selection_endY =controls->mousePositionInWorldY;

                int startX = rectangle_selection_startX;
                int endX = rectangle_selection_endX;
                int startY = rectangle_selection_startY;
                int endY = rectangle_selection_endY;

                if(rectangle_selection_endY <= rectangle_selection_startY)
                {
                    startY = rectangle_selection_endY;
                    endY = rectangle_selection_startY;
                }
                if(rectangle_selection_endX <= rectangle_selection_startX)
                {
                    startX = rectangle_selection_endX;
                    endX = rectangle_selection_startX;
                }


                int tileStartX = startX / TILE_SIZE;
                int tileStartY = startY / TILE_SIZE;
                int tileEndX = endX / TILE_SIZE;
                int tileEndY = endY / TILE_SIZE;

                for(int y = tileStartY ; y <= tileEndY ; y++)
                {
                    for(int x = tileStartX ; x <= tileEndX ; x++)
                    {
                        position_in_array = y * world->map_width + x;
                        if(rectangle_selection_create)
                        {
                            int obj_type = level_editor->active_button->button_type;
                            LevelEditor_CreateObject(category, obj_type, x * TILE_SIZE, y * TILE_SIZE,
                                         position_in_array, controls->mousePositionInWorldX,
                                         controls->mousePositionInWorldY, world, unlimited_creation,
                                         controls->temp_object_to_create->angle);
                        }
                        else if(rectangle_selection_delete)
                        {
                            LevelEditor_UpdateWallsCorners(position_in_array, world);
                            free(world->map[position_in_array]);
                            world->map[position_in_array] = NULL;

                        }
                    }
                }

                if(rectangle_selection_delete)
                {
                    for(int i = 0 ; i < Vector_Count(&world->monsters_vector) ; i++)
                    {
                        Entity* obj = (Entity*)Vector_Get(&world->monsters_vector, i);
                        if(obj->box.right > startX &&
                           obj->box.left < endX &&
                           obj->box.bottom > startY &&
                           obj->box.top < endY)
                        {
                            Entity_Destroy(obj);
                            Vector_Delete(&world->monsters_vector, i);
                        }
                    }
                    for(int i = 0 ; i < Vector_Count(&world->bonus_vector) ; i++)
                    {
                        Entity* obj = (Entity*)Vector_Get(&world->bonus_vector, i);
                        if(obj->box.right > startX &&
                           obj->box.left < endX &&
                           obj->box.bottom > startY &&
                           obj->box.top < endY)
                        {
                            Entity_Destroy(obj);
                            Vector_Delete(&world->bonus_vector, i);

                        }
                    }
                    for(int i = 0 ; i < Vector_Count(&world->props_vector) ; i++)
                    {
                        Entity* obj = (Entity*)Vector_Get(&world->props_vector, i);
                        if(obj->box.right > startX &&
                           obj->box.left < endX &&
                           obj->box.bottom > startY &&
                           obj->box.top < endY)
                        {
                            Entity_Destroy(obj);
                            Vector_Delete(&world->props_vector, i);

                        }
                    }
                    for(int i = 0 ; i < Vector_Count(&world->decals_vector) ; i++)
                    {
                        Entity* obj = (Entity*)Vector_Get(&world->decals_vector, i);
                        if(obj->box.right > startX &&
                           obj->box.left < endX &&
                           obj->box.bottom > startY &&
                           obj->box.top < endY)
                        {
                            Entity_Destroy(obj);
                            Vector_Delete(&world->decals_vector, i);

                        }
                    }
                }
            }

            if((rectangle_selection_create || rectangle_selection_delete) && !pressedKeys[SDLK_LSHIFT])
            {
                rectangle_selection_create = false;
                rectangle_selection_delete = false;
            }


        }





        //deleting every monster
        if(pressedKeys[SDLK_u])
        {
           // Vector_Clear(&world->monsters_vector); leads to memory leak
        }



        //cancel current selected object
        /*if(pressedKeys[SDLK_e])
        {
            level_editor->active_button = NULL;
        }*/



        //switch mobs AI
        if(pressedKeys[SDLK_a] &&
           SDL_GetTicks() - controls->last_ai_switch > 150)
        {
            if(gm->ai_on)
            {
                gm->ai_on = false;
            }
            else
            {
                gm->ai_on = true;
            }

            controls->last_ai_switch = SDL_GetTicks();
        }
    }


}
示例#3
0
void LevelEditor_CreateObject(Main_Category category, int obj_type, int x, int y,
                              int position_in_array, float mousePositionInWorldX,
                              float mousePositionInWorldY, World* world, bool unlimited,
                              float angle)
{

    if(category == Cat_Wall || category == Cat_Door)
    {
        free(world->map[position_in_array]);
        world->map[position_in_array] = Entity_Create(category, obj_type, x, y, angle, world);
    }

    else if(category == Cat_Ground)
    {
        Entity_Destroy(world->ground_map[position_in_array]);
        free(world->ground_map[position_in_array]);
        world->ground_map[position_in_array] = Entity_Create(category, obj_type, x, y, angle, world);
    }

    else if(category == Cat_Zombie &&
       (SDL_GetTicks() - building_time > 150 || unlimited))
    {
        Vector_Push(&world->monsters_vector,
                   Entity_Create(category, obj_type,
                                 mousePositionInWorldX,
                                 mousePositionInWorldY,
                                 0, world));

        building_time = SDL_GetTicks();
    }
    else if(category == Cat_Prop &&
       (SDL_GetTicks() - building_time > 150 || unlimited))
    {
        Vector_Push(&world->props_vector,
                   Entity_Create(category, obj_type,
                                 mousePositionInWorldX,
                                 mousePositionInWorldY,
                                 angle, world));

        building_time = SDL_GetTicks();
    }
    else if(category == Cat_Decal &&
       (SDL_GetTicks() - building_time > 150 || unlimited))
    {
        Vector_Push(&world->decals_vector,
                   Entity_Create(category, obj_type,
                                 mousePositionInWorldX,
                                 mousePositionInWorldY,
                                 angle, world));

        building_time = SDL_GetTicks();
    }
    else if(category == Cat_Event &&
            (SDL_GetTicks() - building_time > 150))
    {
        //there can be only 1 player start and end of level
        for(int i = 0 ; i < Vector_Count(&world->events_vector) ; i++)
        {
            Entity* map_event = (Entity*)Vector_Get(&world->events_vector, i);
            if((obj_type == Event_Player_Start || obj_type == Event_End_Level )&&
               obj_type == map_event->sub_category)
            {
                Vector_Delete(&world->events_vector, i);
            }
        }
        Vector_Push(&world->events_vector, Entity_Create(category, obj_type, x, y, 0, world));
        building_time = SDL_GetTicks();
    }
    else if(category == Cat_Bonus && (SDL_GetTicks() - building_time > 150 ||
                                       unlimited))
    {
        Vector_Push(&world->bonus_vector, Entity_Create(category, obj_type, mousePositionInWorldX, mousePositionInWorldY, 0, world));
        building_time = SDL_GetTicks();
    }

}
示例#4
0
HRESULT App_CookArgList (
   HCMDLIST * phlst,
   LPCTSTR    aArgs[],
   UINT       ixFirst,  // first arg to execute
   UINT       cArgs)    // count of args to execute
{
   HRESULT    hr = S_FALSE; // there were no args...
   TCHAR      szTempArg[64]; // temp if we need to copy and arg

   HCMDLIST   hlst;

   *phlst = NULL;
   hr = Vector_Create(&hlst, cArgs, -1);
   if (FAILED(hr))
      return hr;

   // look at args, parsing switches and building up the array of filename pointers
   //
   UINT ixLast = (ixFirst + cArgs);
   for (UINT ii = ixFirst; ii < ixLast; ++ii)
      {
      LPCTSTR pszArg = aArgs[ii];
      if ( ! pszArg)
         break;

      // assume a file open command.
      //
      hr = S_OK;
      CMDSWITCH cmd = {APP_CMD_PATH, 0, 1, NULL};

      // if the first character of the arg is an '@', what follows should be a command file.
      //
      if (pszArg[0] == '@')
         {
         // command will be an argfile command
         //
         cmd.idCmd     = APP_CMD_ARGFILE;
         cmd.cParams   = 1;    // on arg needed
         cmd.pszParams = NULL; // no default

         // if next character is not a 0, it must be the filename
         // otherwise, suck up the next token and use it as the filename.
         //
         pszArg = StrCharNext (pszArg); // skip '@'
         if (0 != pszArg[0])
            {
            cmd.pszParams = pszArg;
            }
         else if (ii+1 < ixLast) // next pszArg belongs to us..
            {
            LPCTSTR pszT = aArgs[ii+1];
            if ('-' != pszT[0] && '/' != pszT[0])
               {
               cmd.pszParams = pszT;
               ++ii;  // advance the loop counter.
               }
            }
         }
      else if ('-' == pszArg[0] || '/' == pszArg[0])
         {
         pszArg = StrCharNext (pszArg);
         if (0 == pszArg[0])
            {
            hr = E_INVALIDARG;
            goto bail;
            }

         // look for a ':' in the arg, and
         //
         LPCTSTR psz = StrCharNext(pszArg);
         LPCTSTR pszParam = NULL;
         while (0 != psz[0])
            {
            // if the arg contains a colon, set pszParam to point to it
            // and extract the stuff before the colon as the actual arg.
            //
            if (':' == psz[0])
               {
               pszParam = StrCharNext (psz);
               UINT cch = (UINT)(((LPARAM)psz - (LPARAM)pszArg) / NUMBYTES(TCHAR));
               StrCopyN (szTempArg, NUMCHARS(szTempArg), pszArg, cch + 1);
               DASSERT(0 == szTempArg[min(NUMCHARS(szTempArg)-1, cch)]);
               pszArg = szTempArg;
               break;
               }

            psz = StrCharNext(psz);
            }

         // lookup the argment
         //
         if ( ! App_LookupCmdLineArg (g_aAppCommands, pszArg, &cmd))
            {
            bprintfl("%s is not a valid argument", pszArg);
            hr = E_INVALIDARG;
            goto bail;
            }

         if (pszParam)
            {
            if (cmd.cParams < 1)
               {
               // if we have a param, but the arg doesn't take any, bail.
               //
               bprintfl("the %s argument is does not take parameters", pszArg);
               hr = E_INVALIDARG;
               goto bail;
               }

            cmd.pszParams = pszParam;
            }
         else
            {
            // if the command needs args, but none have been found so
            // far, try sucking up the next token in the command line
            //
            if (cmd.cParams > 0 && NULL == cmd.pszParams)
               {
               if (ii+1 < ixLast) // next pszArg belongs to us..
                  {
                  LPCTSTR pszT = aArgs[ii+1];
                  if ('-' != pszT[0] && '/' != pszT[0])
                     {
                     cmd.pszParams = pszT;
                     ++ii;  // advance the loop counter.
                     }
                  }
               }
            }
         }
      else
         {
         // not a switch, this is an implied file-open command
         //
         cmd.pszParams = pszArg;
         }

      // if the command needs an arg, but we dont have one.
      // the command line is in error.
      //
      if ((cmd.cParams > 0) && (NULL == cmd.pszParams))
         {
         bprintfl("the %s argument requires parameters", pszArg);
         g_app.fUsage = true;
         hr = E_INVALIDARG;
         goto bail;
         }

      // append the command.
      //
      Vector_AppendItem(hlst, cmd);
      }

   // return the command list
   //
   *phlst = hlst;

bail:
   if (FAILED(hr) || Vector_GetCountSafe(hlst) < 1)
      {
      *phlst = NULL;
      if (hlst)
         Vector_Delete (hlst);
      }
   return hr;
}
示例#5
0
void GameManage_UpdateWorldEntities(GameManager* gm, World* world)
{
    Vector* bullets_vector = &world->bullets_vector;
    Vector* bonus_vector = &world->bonus_vector;
    Vector* monsters_vector = &world->monsters_vector;
    Vector* explosions_vector = &world->explosions_vector;
    Vector* decals_vector = &world->decals_vector;
    Vector* props_vector = &world->props_vector;


    for(int i = 0 ; i < world->map_size ; i++)
    {
        if(world->map[i] != NULL)
        {
           // Entity_CalculateVisibility(world->map[i], world);
            if(world->map[i]->t == Cat_Door)
            {
                Door_Update(world->map[i], world);
            }

            if(!world->map[i]->alive)
            {
                free(world->map[i]);//walls don't have any compotent, no need to destroy them
                world->map[i] = NULL;
            }
        }
    }



    for(int i = 0 ; i < Vector_Count(bullets_vector) ; i++)
    {
        if(Vector_Get(bullets_vector, i) != NULL)
        {
            Entity* projectile = (Entity*)Vector_Get(bullets_vector, i);
            Entity_CalculateVisibility(projectile, world);

            if(!bullet_time_g)
            {
                if(projectile->t == Cat_Bullet)
                {

                     Bullet_Update(projectile, world);
                }
                else if(projectile->t == Cat_Grenade)
                {
                    Grenade_Update(projectile, world);

                    if(!projectile->alive)
                    {
                        Vector_Push(explosions_vector, Explosion_Create(projectile->x - 64, projectile->y - 64) );
                    }
                }

                if (projectile->alive == false)
                {
                    Entity_Destroy(projectile);
                    Vector_Delete(bullets_vector, i);
                }
            }
        }
        else
        {
            printf("Error during update of bullets vector : bullet = NULL");
        }
    }



    if(gm->ai_on)
    {
        for(int i = 0 ; i < Vector_Count(monsters_vector) ; i++)
        {
            Entity* mob = (struct Entity*)Vector_Get(monsters_vector, i);

            if(Entity_CheckDistance(mob, &world->player, 800))
            {
                Entity_CalculateVisibility(mob, world);
            }

            if(mob->zombieC->aggressive || Entity_CheckDistance(mob, &world->player, 400))
            {
                Zombie_Update(mob, world);
            }



            if (mob->alive == false)
            {
                Zombie_Die(mob, bonus_vector, decals_vector);
                Entity_Destroy(mob);
                Vector_Delete(monsters_vector, i);

            }
        }
    }



    for(int i = 0 ; i < Vector_Count(bonus_vector) ; i++)
    {

        if(Vector_Get(bonus_vector, i) != NULL)
        {
            Entity* bonus = (Entity*)Vector_Get(bonus_vector, i);

            if(Entity_CheckDistance(bonus, &world->player, 800))
            {
                if(!bullet_time_g)
                {
                    Bonus_Update(bonus, &world->player);
                }


                Entity_CalculateVisibility(bonus, world);

            }
            if (bonus->alive == false)
            {
                Entity_Destroy(bonus);
                Vector_Delete(bonus_vector, i);
            }
        }
        else
        {
            printf("Error during update of bonus vector : bonus = NULL");
        }
    }

    for(int i = 0 ; i < Vector_Count(decals_vector) ; i++)
    {

        Entity* decal = (Entity*)Vector_Get(decals_vector, i);

        if(Entity_CheckDistance(decal, &world->player, 800))
        {
            Entity_CalculateVisibility(decal, world);

        }
        if(Vector_Count(decals_vector) > 200)
        {
            if(decal->is_ennemy)
            {
                Vector_Delete(decals_vector, i);
            }
        }

    }

    for(int i = 0 ; i < Vector_Count(props_vector) ; i++)
    {
        Entity* prop = (Entity*)Vector_Get(props_vector, i);

        if(Entity_CheckDistance(prop, &world->player, 800))
        {
            Entity_CalculateVisibility(prop, world);
        }
        if (!prop->alive)
        {
            Entity_Destroy(prop);
            Vector_Delete(props_vector, i);
        }
    }





    for(int i = 0 ; i < Vector_Count(explosions_vector) ; i++)
    {
        Entity* exp = (Entity*)Vector_Get(explosions_vector, i);
        if(!bullet_time_g)
        {
            Explosion_Update(exp, world);
        }

        Entity_CalculateVisibility(exp, world);
        if (!exp->alive)
        {
            Entity_Destroy(exp);
            Vector_Delete(explosions_vector, i);
        }
    }
}