-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBGSpriteComponent.h
More file actions
36 lines (31 loc) · 990 Bytes
/
BGSpriteComponent.h
File metadata and controls
36 lines (31 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include "SpriteComponent.h"
#include <vector>
#include "Math.h"
// This is a class pspecifically for handling background images
class BGSpriteComponent : public SpriteComponent
{
public:
// set a low draw order
BGSpriteComponent(class Actor* owner, int drawOrder = 10);
//update/draw overriden from parent
void Update(float deltaTime) override;
void Draw(SDL_Renderer* renderer) override;
// Set textires for background
void SetBGTextures(const std::vector<SDL_Texture*>& textures);
// get/set the screen size and the scroll speed
void SetScreenSize(const Vector2& size) { mScreenSize = size; }
void SetScrollSpeed(float scrollSpeed) { mScrollSpeed = scrollSpeed; }
float GetScrollSpeed() const { return mScrollSpeed; }
private:
// Structure to encapsulate each BG image and its offset
struct BGTexture
{
SDL_Texture* mTexture;
Vector2 mOffset;
};
// member variables
Vector2 mScreenSize;
std::vector<BGTexture> mBGTextures;
float mScrollSpeed;
};