Hi all, i need some help with my tetris like game, im new in SDL, and i can't figure it out how to add new pieces i can make a piece appears, and then, when it touches the bottom, a new piece appears, but its something like this...
SDL_BlitSurface( image, &sel1[frame], screen, ▭
rect.y++;
if (rect.y==348)
{
SDL_BlitSurface( image, &sel1[frame], screen, &rect2);
}
so.. this code create a piece then it descends to the bottom then a new piece appears, but I have problem with the rect position.. i guess i need an SDL_Rect array? or something like that? ...I want it to continue appearing pieces indefinitely, do i need to create an array? or something like SDL_BlitSurface = NEW SDL_BlitSurface ? like in C#... im pretty sure that i missing something important here....
And also need to know when i need to clear the line? I don't know how to set the condition .... something like if (the first space is occupied && the second is occupied && etc..) but how do i know that the space is occupied?
This is kinda what i have:
SDL_Surface* screen, *image;
screen = SDL_SetVideoMode( 186, 348, 32, SDL_SWSURFACE );
SDL_FillRect(screen,&screen->clip_rect,color);
SDL_BlitSurface( image, &sel1[frame], screen, &inPos);
...so with this i dont think that i can make a comparison for the if...the only thing that i can think is something like ... if (rect.y==348)/*Bottom*/ , and /*&&*/ rect.x==0 /*left*/ then ... the first space is occupied but how can i know that an image is in there? ... i guess i need some graphic comparision o i dont know
i saw in a tetris tutorial something like this:
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 0 1 0
but is something like a board but i cant find anything about this in SDL ... do i need OPENGL? its a little confusing :S ... sorry if im too noob with game programing and thank you all for your help
TL;DR?.. my 2 questions are: how to create or appear pieces indeterminately or forever... And How I can compare or know that all the spaces are filled to clear a line? ..only with c++ and SDL?
thank you very much!!