Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access