hey everyone here !!! wishing everything is great for everyone !!!
I'm a newbie here and i don't know if this correct but i really to learn how to do something , im trying lo load a map in a screen , and the thing is the map load correctly but every time..i load another image the screen is flickering in addition when I Get full screen is like a chess board.. I would like a litle help
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window *window = SDL_CreateWindow("titu", SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED, S_W,S_H, SDL_WINDOW_SHOWN/*SDL_WINDOW_FULLSCREEN*/);
SDL_Renderer *render = SDL_CreateRenderer(window, -1 , SDL_RENDERER_ACCELERATED |SDL_RENDERER_PRESENTVSYNC);
SDL_Event ev;
bool salir = true;
SDL_Rect rect={0,0,32,32};
int arreglo[MAX_ROW][MAX_COL]={
/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 */
{1,1,1,1,1,1,1,1,1,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2},
{2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2},
{2,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2}
};
for(int i= 0; i < MAX_COL ; i++)
{
///cout <<endl;
for(int j=0; j < MAX_ROW;j++){
if(arreglo[j][i] == 2) //// correcto.
rect.x =32;
else if(arreglo[j][i]==1)
rect.x = 0;
else if(arreglo[j][i]==3)
rect.x = 64;
///cout << arreglo[j][i]<<',';
DrawMap(render, &rect, i*32,j*32,32); ///copy the render in the screen.
SDL_RenderPresent(render);
}
}
obviously i have a game loop where I make a litle delay using : 1000/fps -(startime-lastime)
i dont put it because the whole code is at home ... but the idea is clear , is what i believe..
thank you .