Finishing the CameraGraphics class
In this section, we will revisit, amend, and add to our CameraGraphics
class. First, we will add some background and shader-related variables to our CameraGraphics.h
file. At the end of the private section of CameraGraphics.h
, add the following variables:
//For the shaders and parallax background
Shader m_Shader;
bool m_ShowShader = false;
bool m_BackgrounsAreFlipped = false;
Clock m_ShaderClock;
Vector2f m_PlayersPreviousPosition;
Texture m_BackgroundTexture;
Sprite m_BackgroundSprite;
Sprite m_BackgroundSprite2;
In the preceding code we have an SFML Shader
called m_Shader
and a Boolean called m_ShowShader
, which we can use to track when to show the shader or not. For this game, we will flip between ten seconds of showing the shader and ten seconds of showing the parallax background.
The Boolean m_BackgroundsAreFlipped
will be used to determine whether the texture that represents the background is horizontally reversed. We do this to...