I am writing a game using C# 2010 and XNA 4.0. I want it to be a good game and not some "just another crap" and so one of my goals is good framerate. For this I would like to ask you for some advices, be it XNA related or C# related - what can I do to speed up my code and so improve FPS.
Here is some stuff I found out:
array
insted of list<>
will improve performance a lot, in case you want to access huge amount of data (or even lots: having an array of 20000 items gave almost 180% FPS of list of 20000.for
instead of foreach
will improve performance. On same 20000 elements it's like 5-10% difference.drawuserprimitives
and not Model
class. (no idea if it is 4.0 only, or 3.1 had such performance problem too)Ok, so to make long story short, please post some good advice here, so I / we can make good, fast and optimized games ;)
Thanks in advance: Zéiksz
Software optimisation is a craft. The best kinds of optimisation are evidence based on collected statistics.
Until you have a problem don't optimise. Don't you think that game playability is more important than this metric or another? My suggestion is make the game first and then consider where it's not performing as you'd like.
Then post some specific questions and I'm sure you'll get some help here on the specific issues.
In the mean time I suggest that you'll get more information from games development books like those listed here : http://forums.create.msdn.com/forums/p/8642/45646.aspx.
XNA Extereme 101 - seems to be an interesting tutorial