O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

What are we doing here? At the beginning, the sky's left border is the same as the view's left border, both at point (0, 0). At the end, when Benjamin has walked to the maximum right, the sky's right border should be the same as the view's right border. So, at this position, the shift of the sky will be equal to the sky's width (m_sky->boundingRect().width()) minus the width of the view (width()). The shift of the sky depends on the position of the camera and, consequently, the value of the m_worldShift variable; if it is far to the left, the sky isn't shifted, and if the camera is far to the right, the sky is maximally shifted. Thus, we have to multiply the sky's maximum shift value with a factor based on the current ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required