Ejemplo n.º 1
0
void GameWorldView::SetNextZoomFactor()
{
    if (zoomFactor_ == targetZoomFactor_) // == with float is ok here, is explicitly set in last step
        return;

    float remainingZoomDiff = targetZoomFactor_ - zoomFactor_;

    if (std::abs(remainingZoomDiff) <= 0.5 * zoomSpeed_ * zoomSpeed_ / ZOOM_ACCELERATION)
    {
        // deceleration towards zero zoom speed
        if (zoomSpeed_ > 0)
            zoomSpeed_ -= ZOOM_ACCELERATION;
        else
            zoomSpeed_ += ZOOM_ACCELERATION;
    }
    else
    {
        // acceleration to unlimited speed
        if (remainingZoomDiff > 0)
            zoomSpeed_ += ZOOM_ACCELERATION;
        else
            zoomSpeed_ -= ZOOM_ACCELERATION;
    }

    if (std::abs(remainingZoomDiff) < std::abs(zoomSpeed_))
    {
        // last step
        zoomFactor_ = targetZoomFactor_;
        zoomSpeed_ = 0;
    }

    zoomFactor_ = zoomFactor_ + zoomSpeed_;
    CalcFxLx();
}
Ejemplo n.º 2
0
/**
 *  verschiebt das Bild zu einer bestimmten Stelle.
 *
 *  @author FloSoft
 */
void GameWorldView::MoveTo(int x, int y, bool absolute)
{
    if(absolute)
    {
        xoffset = x;
        yoffset = y;
    }
    else
    {
        xoffset += x;
        yoffset += y;
    }

    CalcFxLx();
}
Ejemplo n.º 3
0
void GameWorldView::MoveTo(const DrawPoint& newPos, bool absolute)
{
    if(absolute)
        offset = newPos;
    else
        offset += newPos;

    DrawPoint size(GetWorld().GetWidth() * TR_W, GetWorld().GetHeight() * TR_H);
    if(size.x && size.y)
    {
        offset.x %= size.x;
        offset.y %= size.y;

        if(offset.x < 0)
            offset.x += size.x;
        if(offset.y < 0)
            offset.y += size.y;
    }

    CalcFxLx();
}
Ejemplo n.º 4
0
void GameWorldView::Resize(unsigned short width, unsigned short height)
{
    this->width  = width;
    this->height = height;
    CalcFxLx();
}
Ejemplo n.º 5
0
GameWorldView::GameWorldView(GameWorldViewer* gwv, unsigned short x, unsigned short y, unsigned short width, unsigned short height) : selx(0), sely(0), show_coordinates(false), show_bq(false), show_names(false), show_productivity(false), xoffset(0), yoffset(0), last_xoffset(0), last_yoffset(0), gwv(gwv), d_what(0), d_player(0), d_active(false), x(x), y(y), width(width), height(height), terrain_list(0), terrain_last_xoffset(0), terrain_last_yoffset(0), terrain_last_global_animation(0), terrain_last_water(0)
{
    CalcFxLx();
}