ash, how does this go about rendering its maps? it seemed to take a while for the PRIZM's fancy pants hardware, so i thought you must be doing something fancypants yourself and wanted to ask before looking at the source.
Well, it really isn't much. I just realized no matter how much I optimize the rendering process, it'll still be slow, since it's pretty simplistic:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| void drawtilemap(city_cell*map, int xpos, int ypos) { city_cell*cur_element = 0x00000000; const char*tile = 0x00000000; for(int j = 0; j < 10 ; j++) { for(int i = 0; i < 20; i++) { cur_element = access_map_element(map, xpos+i, ypos+j); if(cur_element->occupied) { switch(cur_element->occupied_type) { case utility: break; case residential: case commercial: case industrial: tile = ((cur_element->occupied_type-1)*512)+zoning_tiles; break; case school: break; case police: break; case firestation: break; case hospital: break; case road: break; case political: break; case park: break; case landmark: break; case ruins: break; } } else { switch(cur_element->natural_cell){ case grass: tile = grass_tile; break; case water: tile = water_tile; break; case dirt: tile = dirt_tile; break; case sand: tile = sand_tile; break; case tree: tile = tree_tile; break; case mountain: tile = mountain_tile; break; } } CopySprite(tile, i*16, j*16+56, 16, 16); tile = 0x00000000; } } } |
What I did to make sure it runs fast is create an organized system of Renderloops controlled by a single one, and within the renderloops check to see if anything had to be done or changed; if not, do nothing. Also made sure that you couldn't do much at one single time within the renderloop, i.e. only one process at a time. The main helper here isn't that the rendering process is fancypants, but rather I just used good coding regimes
