Search code examples
c#xna2d-games

Storing 100 vectors XNA


I'm making a 2D top down survival game, maximum sprite count for the top level is 100 sprites. When I use a random to generate their vector positions occasionally i'll get some overlap between sprites.

So to combat this i'm going to store some pre-defined positions.

The question

So my question is what would be the best way of storing these. Initially i was going to store them in an array, however i'm thinking that storing them in a text file and reading them in at the start of the game would be a better solution.

I'm a beginner so if anyone could give any advice on this it would be much appreciated.

Many thanks


Solution

  • Yes store them in a CSV (comma separated values) text file, or if you want, use a database, although I would recommend the former. Database storage sounds like overkill in your situation. On start-up you would load the values into an array. If you don't the game will lag every time it gets a value. You just need the text file for persistent storage and then the array for usage.

    Hope this clears your issue up for you!