Is it possible to create a vector of SDL_Rects?

Is it possible to create a vector of SDL_Rects?

Postby gordebak » 31 Jan 2011, 10:46

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?
User avatar
gordebak
MnMS Moderator
 
Posts: 50
Joined: 28 Jan 2011, 04:52
Location: Ankara, Turkey

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

Postby gordebak » 31 Jan 2011, 11:33

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?
User avatar
gordebak
MnMS Moderator
 
Posts: 50
Joined: 28 Jan 2011, 04:52
Location: Ankara, Turkey

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

Postby oln » 31 Jan 2011, 14:45

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.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

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

Postby gordebak » 31 Jan 2011, 17:53

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.
User avatar
gordebak
MnMS Moderator
 
Posts: 50
Joined: 28 Jan 2011, 04:52
Location: Ankara, Turkey

Who is online

Users browsing this forum: No registered users and 0 guests