Ejemplo n.º 1
0
const std::vector<Lines<float> > Algorithms::twoDToIsoVector(const std::vector<Lines<float> > linesNormalized){
    std::vector<Lines<float> > linesNormalizedIso;
    for(std::vector<Lines<float> >::const_iterator it = linesNormalized.begin(); it != linesNormalized.end(); ++it) {
        Lines<float> lineNormalizedIso = twoDToIso(*it);
        linesNormalizedIso.push_back(lineNormalizedIso);
    }
    return linesNormalizedIso;
}
Ejemplo n.º 2
0
void drawTileFromGridPoint(SDL_Renderer* ren, Point *p, SDL_Rect *clip)
{
    p->x *= GRID_TILE_SIZE;
    p->y *= GRID_TILE_SIZE;
    //printf("(%d,%d) -> ", p.x, p.y);
    twoDToIso(p);
    //printf("(%d,%d)\n", p.x, p.y);
    p->x += screen_x;
    p->y += screen_y;
    renderTextureClip(sheet, ren, (p->x - ((clip->w)>>1)), (p->y - clip->h), clip);
}
Ejemplo n.º 3
0
void draw_city(SDL_Renderer* ren)
{
    Point p;
    int x,y;
    SDL_Rect *clip;
    for(x=1; x<MAP_SIZE_X; x++) {
        bool drew_in_this_x = false;
        for(y=1;y<MAP_SIZE_Y; y++) {
            p.x = x*GRID_TILE_SIZE;
            p.y = y*GRID_TILE_SIZE;
            twoDToIso(&p);
            p.x += screen_x;
            p.y += screen_y;
            clip = getTileClip(map_value[x][y]);

            if(p.x < -clip->w) {
                break;
            } else if( p.y > (window_size_y + clip->h) ) {
                break;
            }
            drew_in_this_x = true;
            drawTile(ren, &p, clip);
            draw_animation_tile(ren, x, y);
        }
        if(!drew_in_this_x && p.y > (window_size_y + clip->h)) {
            break;
        }
    }
    p.x = down_point.x*GRID_TILE_SIZE;
    p.y = down_point.y*GRID_TILE_SIZE;
    //printf("(%d,%d) -> ", p.x, p.y);
    twoDToIso(&p);
    //printf("(%d,%d)\n", p.x, p.y);
    p.x += screen_x;
    p.y += screen_y;
    drawTile(ren, &p, getTileClip(TILE_HIGHLIGHT_BLUE));

    p.x = up_point.x*GRID_TILE_SIZE;
    p.y = up_point.y*GRID_TILE_SIZE;
    //printf("(%d,%d) -> ", p.x, p.y);
    twoDToIso(&p);
    //printf("(%d,%d)\n", p.x, p.y);
    p.x += screen_x;
    p.y += screen_y;
    drawTile(ren, &p, getTileClip(TILE_HIGHLIGHT_BLUE));

    if(ready_to_place) {
        Point p2;
        switch(getMode()) {
            case MODE_BUILD_ROAD:
                p = plan_down;

                p2 = plan_down;
                draw_highlight(ren, &plan_down);
                plan_down = p2;
                while(p.x != plan_up.x) {
                    if(p.x < plan_up.x) {
                        p.x += 1;
                    } else {
                        p.x -=1;
                    }
                    p2 = p;
                    draw_highlight(ren, &p);
                    p = p2;
                }
                while(p.y != plan_up.y) {
                    if(p.y < plan_up.y) {
                        p.y += 1;
                    } else {
                        p.y -=1;
                    }
                    p2 = p;
                    draw_highlight(ren, &p);
                    p = p2;
                }
                break;
            case MODE_BUILD_RESIDENTIAL_1:
            case MODE_BUILD_RESIDENTIAL_2:
            case MODE_BUILD_RESIDENTIAL_3:
            case MODE_BUILD_DESTROY:
            case MODE_BUILD_LANDFILL:
            case MODE_BUILD_RETAIL:
            case MODE_BUILD_POWER_SOLAR:
            case MODE_BUILD_POWER_WIND:
            ;
                //p = plan_down;
                //p2 = plan_down;
                //drawTileFromGridPoint(ren, &plan_down, getTileClip(TILE_HIGHLIGHT_GREEN));
                //plan_down = p2;
                int x, y;
                for(x = MIN(plan_down.x, plan_up.x); x<=MAX(plan_down.x, plan_up.x); x++) {
                    for(y = MIN(plan_down.y, plan_up.y); y<=MAX(plan_down.y, plan_up.y); y++) {
                        p.x = x;
                        p.y = y;
                        draw_highlight(ren, &p);
                    }
                }
                break;
            case MODE_BUILD_HOSPITAL:
            case MODE_BUILD_POLICE:
            ;
                p.x = plan_up.x;
                p.y = plan_up.y;
                draw_highlight(ren, &p);
                break;
            case MODE_BUILD_POWER_GAS:
            case MODE_BUILD_POWER_NUCLEAR:
            case MODE_BUILD_SCHOOL:
            case MODE_BUILD_PARK:
            ;
                p.x = plan_up.x;
                p.y = plan_up.y;
                draw_highlight(ren, &p);
                p.x = plan_up.x+1;
                p.y = plan_up.y;
                draw_highlight(ren, &p);
                p.x = plan_up.x;
                p.y = plan_up.y+1;
                draw_highlight(ren, &p);
                p.x = plan_up.x+1;
                p.y = plan_up.y+1;
                draw_highlight(ren, &p);
                break;
            case MODE_BUILD_STADIUM:
            ;
                int x1, y1;
                for(x1 = 0; x1<4; x1++) {
                    for(y1 = 0; y1<4; y1++) {
                        p.x = plan_up.x+x1;
                        p.y = plan_up.y+y1;
                        draw_highlight(ren, &p);
                    }
                }
                break;
			default:
				break;
        }
    }

    draw_animation_overlay(ren);
}