Members - Reputation: 406
Posted 22 June 2012 - 06:37 PM
I am working on a tower defense game using XNA 4.0.
I have gotten to a point where I am questioning if I am doing things the right way, and if there is a better to do some of what im doing. For the most part, most of my logic seems to be countless foreach or for loops going through lists of enemies or towers, etc and apply some calculations or conditionals on properties.
I feel like the more complex my game will get, the more lists and loops Ill have to add to check each enemy and tower for information. As the lists grow, the game starts to slow down. How can I handle this differently?
Basically my level has a List<Enemy> enemies and a List<Tower> towers.
In an public void Update(GameTime gameTIme) function there are a few foreach loops doing some logic on positions, alive, distance, etc.
Suggestions on how to handle this better?
Follow me @jmillerdev
Crossbones+ - Reputation: 5554
Posted 22 June 2012 - 06:47 PM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
Members - Reputation: 879
Posted 23 June 2012 - 12:45 AM
I suggest you post your Update code, it may help you get some feedback.