-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackground.cpp
More file actions
26 lines (23 loc) · 771 Bytes
/
Background.cpp
File metadata and controls
26 lines (23 loc) · 771 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
#include "Background.h"
using namespace sf;
Background::Background(RenderWindow & window_ref)
{
int size=200;
for(int i=0;i<5;i++){
shapes[i].setSize(Vector2f(size,size));
int offset=15;
shapes[i].setOrigin(size/2,size-offset);
float factor=((rand()%400)+700)/1000.0f;
shapes[i].scale(factor,factor);
shapes[i].setFillColor(Color(255,255,255,220));
shapes[i].setPosition( window_ref.getSize().x - 150*(i+1) + ((rand()%50)-25) , window_ref.getSize().y);
}
}
void Background::update(){
for(int i=0;i<5;i++)
shapes[i].setTexture(sprites[i].getFlagTexture());
}
void Background::draw(RenderTarget& target,RenderStates states) const{
for(int i=0;i<5;i++)
target.draw(shapes[i]);
}