- Make sure that this piece of code is actually the performance bottle neck. Even though you are using xxxGL, drawing may be time consuming.
Review the list types you are using and make sure they are efficient for the operations you are performing on them. For example, depending on the type of the cell list,
for (int i = 0; i < cell.Count(); i++) { if (cell[i].dies) { if (animated && delay == 50) { cell.RemoveAt(i); cellsdied += 1; i--; } else { cell[i].willdie = true; } } }
this code may be really slow because of the RemoveAt(i), i-- style you are using to iterate.
3.Consider keeping some of your data structures around and updating them instead of building new lists and objects. A cell can be thought of to exist for the lifetime of the game. Sometimes it is dead, other times it is dying, or alive, but the cell object does not need to be deleted or recreated. I'm a little outside of my knowledge base with C#, but calls to 'new' involve memory allocation, and are more expensive than keeping an object around and modifying its state.