How to create multiple SDL_Rects from one


#1

I want to make a breakout clone in SDL2. I want to make one SDL_Rect and cloning it in different coordinates. Any help would be appreciated


#2

If you are about your divider, I implemented it already.

image


#3

Another solution would be the declaration of multiple rects in the globals.

SDL_Rect divider[30];

Initialize them in your set/init game:

	for (int i=0; i<30; i++){
		divider[i].w =   4;
		divider[i].h =  10;
		divider[i].x = 398;
		divider[i].y = 5+i*(divider[i].h*2);
	}

and finally render them:

for (int i=0; i<30; i++){
    SDL_RenderFillRect(Renderer, &divider[i]);
}

-Cass


#4

But seriously, create an github account, fork my project and work there.
I already fixed all your Game-State issues in:


You want to run a function in your main-loop that checks the game-state and calls the belonging state-driver function.