Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/349752724633567232
edited tags
Link
Tetrad
  • 30.1k
  • 12
  • 95
  • 143
Source Link

When to use an Array vs When to use a Vector, when dealing with GameObjects?

I understand that from other answers, Arrays and Vectors are the best choices. Many on SE claim that Linked Lists and Maps are bad for video game programming.

I understand that for the most part, I can use Arrays. However, I don't really understand exactly when to use Vectors over Arrays.

Why even use Vectors? Wouldn't it be best if I simply always used an Array, that way I know how much memory my game needs?

Specifically my game would only ever load a single "Map" area of tiles, such as Map[100][100], so I could very easily have an array of GameObjectContainer GameObjects[100][100], which would reserve an entire map's worth of possible gameobjects, correct?

So why use a Vector instead? Memory is quite large on modern hardware.