Standards Showcase 1 - Camera Zoom and Rotation
Автор: Andrew Matzureff
Загружено: 2018-08-25
Просмотров: 109
Описание:
After prototyping the system of interactions between parallax layers and the camera the next goal was to create a more versatile camera, one that comes equipped with most of the features that the majority of modern 2D games should make use of. This includes rotation and scaling.
The transformation framework is very simple as are our requirements for orienting entities in the world.
Procedure A (Camera & Layer Transform):
0) The graphics context must first be transformed according to the camera's spatial characteristics with respect to the current parallax layer.
1) The context is rotated by the angle of the camera minus the angle of its subject or target (which is ideally the same value) unless the camera angle is fixed (in which case nothing is subtracted).
2) The context is scaled by the camera's zoom factor.
3) The camera translation (scaled according to the current parallax layer) is now applied. This consists of the parallax scaled position offset and the un-scaled viewport offsets for correcting the pseudo 3D perspective. These values are half the corresponding canvas (or 'render target') dimensions.
Also, keep in mind that the order in which we concatenate each transform matters. If we were representing the rotation (R), scale (S), and position (P) as matrices, the net transformation could be represented using the following matrix product: P*S*R.
Procedure B (Entity Transform):
0) This process is pretty straightforward as all that remains is transforming the context by the entity's spatial characteristics exactly, with the exception of scale.
1) Translate by entity position.
2) Rotate by entity angle.
3) Scale the graphics context by the entity scale multiplied by the current layer such that layer is greater than 0 or by the entity scale by itself when layer = 0. Negative layers are a special case for which we're still trying to decide the best course of action. At the moment, we simply shift and mirror the scaling phase so that the scaling of layers (-infinity, 0) mimics the appearance of that of layers (0, +infinity).
On negative layers... the reason we kept negative parallax layers a possibility is because they can be used to imply a rotating play field and add a new dimension of depth to our 2D game world.
Josh's Channel:
/ thewalkthroughkiller
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: