   Cell Storage Algorithm Help
  I need some tips on how I can improve this idea that I've come up with. If anyone has any advice, I would appreciate it. Come on, don't chicken out because this text is big and confusing!!Background Info (not needed for the question):The graphics in my game are seperated into cells. Each character has seperate images for head, body, legs, weapon, and shield. Each of those images have a number of cells drawn in them, but not in a grid format. Each cell can be in any position within its image, and a unique color is reserved for lines that seperate the cells. My animation editor uses the colored lines to scan from a clicked region outward to find the cell coordinates for an individual frame. That make sense?In my datafile program, I convert my celled-images into image lists. It finds each cell within the image, crops all transparency from its edges, and stores it in a bitmap list.The question:Once my game starts, I need to convert my animation editor's "cell coordinates" into image list indexes for each frame. Makes total sense, right? This is my problem:   for(int anim=0; anim<About50Anims; anim++){for(int frame=0; frame < About5To15Frames; frame++){for(int cell=0; cell < Exactly5Cells; cell++){for(int bmpcell=0; bmpcell < About300; bmpcell++){if(anim->frame->cell->coordX == bmpcell->coordX&& anim->frame->cell->coordY == bmpcell->coordY){anim->frame->cell->index = bmpcell;break; // only from bmpcell loop}}}}}Should I be worried about this? I'm afraid that as my number of animations and cells grow, so too will this loop, drastically. The animations * bmpcells is what has me worried. Even though the number of animations is around 50 now, the total animations for the game is going grow to around 400% of that. And on average, each new animation needs around 4-5 new bmpcells.Is there anything I can do to lower the total iterations? Should I not be concerned at all?Thanks for any help!EDIT: Damn less-than signs.[edited by - Jiia on April 5, 2004 8:00:04 AM]
  I''m not sure I understand your problem, but here goes:You probably don''t need to process every bmpcell of every cell of every frame of every anim, every pass. Before entering this massive loop, trim out what you know you don''t need to process. Currently, you''re  doing the inner loop 750,000 times! Before entering the loops, construct lists of only those items you know you need to process. For example, if you know only 3 anims are active on the screen, there is no need to process the other 47. If you know those 3 anims only use 7 of the 300 bmpcells, only check those 7 and not the other 293 - create a temp array of the 7, and loop through that.Or is this "one time" processing, only done at startup? If so, don''t worry about it. Again, I''m not sure what you''re really trying to accomplish. ;  Thanks for the suggestions. It''s at startup, and I do need to convert them all at once. I was hoping I wouldn''t have to worry about it. I would still like to know if anyone can see a smarter way to do this.Ranted explanation:All characters in my game share the same animations. The cells in each bitmap can have extra padding around them to allow me to use the same cells for different looking characters. Such as giving a specific character long hair. Other characters would use the same head-cell coordinates for the same frames, but they would have a huge blank space around their head in each cell. Cells can be any size. Head cell 1 could be 40x50, then cell 2 can be 335x8.My datafile program takes the original big image, and converts each cell within it into a cropped bitmap, removing that extra padding where it''s not needed, and storing the original coordinates in the file. Then it stores them all in a list. So in the game, I need to use indexes instead of coordinates.I don''t want my animation editor to work off of the same data, because of the way I process the cell images (from left-right, top-bottom), because adding a new cell to the right of an old one would offset everything below it by one cell. So it must store them as coordinates.LMAO! As if anyone is bored enough to read this far. Sorry to GameDev for adding another 2K of ranting bytes 