Author Topic: [Prizm 2011 Contest Entry] PrizmCity  (Read 17453 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
Re: [Prizm 2011 Contest Entry] PrizmCity
« Reply #45 on: September 16, 2011, 07:45:53 pm »
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:

Code: [Select]
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 :)