-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackground.cpp
More file actions
51 lines (39 loc) · 1.2 KB
/
Background.cpp
File metadata and controls
51 lines (39 loc) · 1.2 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Background.hpp"
Background::Background(sf::Vector2u targetSize) {
_pivot = sf::Vector2f(targetSize.x/2.0,targetSize.y/2.0);
_test.setTexture(Resources::textureTest);
layers.push_back(Layer(10));
layers.push_back(Layer(10));
layers.push_back(Layer(10));
layers[0].setFactor(0.0);
layers[1].setFactor(0.3);
layers[2].setFactor(2.5);
layers[0].setTexture(Resources::layer0,3);
layers[1].setTexture(Resources::layer2,5);
layers[2].setTexture(Resources::layer1,5);
}
Background::~Background() {}
void Background::setSpeed(float speed){
for(int i = 0; i < layers.size(); ++i){
layers[i].setSpeed(speed);
}
}
void Background::draw(sf::RenderTarget* target) {
//Draw some thiings
target->draw(_test,_transform);
//for each layer
for(int i = 0; i < layers.size(); ++i){
layers[i].draw(target, &_transform);
}
// Draw layers here :D
}
void Background::update(float deltaTime){
//for each layer, update layer
for(int i = 0; i < layers.size(); ++i){
layers[i].update(deltaTime);
}
}
void Background::setRotation(float rotation) {
_transform = sf::Transform::Identity;
_transform.rotate(rotation,_pivot.x,_pivot.y);
}