few weeks ago I posted a little programming feature on particles and some of you were happy.
I was writing today a little prototype as a continuation of my tooth-fairy game and started to think that this might be something worth sharing.
When I write a prototype, I tend to create static helper classes.
These are comparable to what some people do in C with some define.h file containing all the game's global variables.
I do it for assets (Textures, Sounds, Musics) and also for SoundManager functions.
During prototyping, I rarely run close to any kind of hardware limitation (Processing power nor memory usage) and this make it easy to use the same sound from different classes without having to play with references, pointers (depending on what language I use).
You will also want to have your assets named something like "tree1.png" "tree2.png" etc...
So you can load it all in a list in one for loop.
In C# XNA:
List<Texture2D> treeList = new List<Texture2D>();
....
for(int i = 0; i < treeAmount; i++)
{
treeList.Add(Load("tree" + i + ".png"));
}
....
And finally in your forest class, something pseudo like this:
for(Allmytree)
{
canvas.Draw(GraphicStorage.treeList[theTreeIWantYay]);
}
.....
Now the question why would you not want to always do that?
In bigger project, you don't want always all the assets loaded at the same time, it is easier to manage what needs to be loaded if the object themselves take care of the loading.
....
I'll try to write short stuff like this every time something pop up to my mind!