-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsun.cpp
More file actions
45 lines (34 loc) · 948 Bytes
/
Copy pathsun.cpp
File metadata and controls
45 lines (34 loc) · 948 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
36
37
38
39
40
41
42
43
44
45
#include "sun.h"
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
const float END_OF_WINDOW = 600.f;
void Sun::initTexture(){
this->texture.loadFromFile("extrafile/sun.png");
}
bool Sun::hasArrivedToDown(){
return this->sprite.getPosition().y > END_OF_WINDOW ;
}
void Sun::initSprite(){
this->sprite.setTexture(this->texture);
this->sprite.scale(.15f, .15f);
this->sprite.setOrigin(sprite.getLocalBounds().width / 2, sprite.getLocalBounds().height / 2);
}
Sun::Sun(int _speed){
speed = _speed;
this->initTexture();
this->initSprite();
}
void Sun::setPosition(float x, float y) {
this->sprite.setPosition(x, y);
}
void Sun::move(const float dirX , const float dirY){
this->sprite.move(this->speed * dirX ,this->speed * dirY);
}
void Sun::render(sf::RenderTarget& target){
target.draw(this->sprite);
}
const sf::Sprite& Sun::getSprite() const{
return sprite;
}