Page 1 of 1

Is it possible to create a vector of SDL_Rects?

PostPosted: 31 Jan 2011, 10:46
by gordebak
I'm just learning. So I wonder if it's possible to create a vector of SDL_Rects?

I made a simple box with collision detection with the player. But if I could made the rects in a vector, I could test their collision with the same functions by loops. Is it a good approach?

I tried to create a vector, compiler didn't complain. But I couldn't put the rects on screen. Any ideas?

Re: Is it possible to create a vector of SDL_Rects?

PostPosted: 31 Jan 2011, 11:33
by gordebak
AFAIU, from an answer in another forum, this should be possible. I wonder if this is a good approach for storing the data of boxes and checking for collision. Will it slow down the program?

Re: Is it possible to create a vector of SDL_Rects?

PostPosted: 31 Jan 2011, 14:45
by oln
Can't see why it shouldn't be possible to store SDL_Rects in a vector. Maybe you could direct us to the code if you are still having problems.

Re: Is it possible to create a vector of SDL_Rects?

PostPosted: 31 Jan 2011, 17:53
by gordebak
I figured it out. Yeah, it's possible.

Problem was me trying to get the size of the vector for a loop before storing anything in it. It was 0 of course. It works fine now.