#define DECK_SIZE 40
class Deck
{
Card cards[DECK_SIZE];
// Other deck stuff here
};
class Deck
{
Vector<Card> cards;
// Other deck stuff here
};
#define DECK_SIZE 40
class Deck
{
Card cards[DECK_SIZE];
// Other deck stuff here
};
class Deck
{
Vector<Card> cards;
// Other deck stuff here
};
Quote:
Original post by -Datriot-
allocating and freeing memory every time a card is added or removed?
Quote:
allocating and freeing memory every time a card is added or removed
Quote:
Original post by -Datriot-
it might be a lot faster to have a static array over the dynamic vector.
*** Source Snippet Removed ***
Would allocating memory for 40 cards when the deck is created have less of an impact on performance instead of allocating and freeing memory every time a card is added or removed?
Quote:For something like a card game this isn't going to be an issue at all. We use the STL all over the place in our code at work (DS driving games), and it's never been a problem. As Zahlman said, this is where reserve() comes in.
Original post by -Datriot-
I was thinking with the DS being very limited in terms of performance, it might be a lot faster to have a static array over the dynamic vector.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more