forked from LegatAbyssWalker/SpaceInvaders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUFO.cpp
46 lines (35 loc) · 954 Bytes
/
UFO.cpp
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
#include "UFO.h"
UFO::UFO() {
texture.loadFromFile("res/images/SIUFO.png");
sf::Vector2<unsigned> UFOChar = texture.getSize();
UFOChar.x /= 1;
UFOChar.y /= 1;
ufo.setTexture(texture);
ufo.setTextureRect(sf::IntRect(UFOChar.x * 0, UFOChar.y * 0, UFOChar.x, UFOChar.y));
ufo.setOrigin(UFOChar.x / 2, UFOChar.y / 2);
ufo.scale(1 * 1.5, 1 * 1.5);
}
void UFO::renderTo(sf::RenderWindow& window) {
window.draw(ufo);
}
void UFO::setUFOPos(sf::Vector2<float> newPos) {
ufo.setPosition(newPos);
}
void UFO::moveTo(sf::Vector2<float> distance) {
ufo.move(distance);
}
int UFO::getX() {
return ufo.getPosition().x;
}
int UFO::getY() {
return ufo.getPosition().y;
}
sf::FloatRect UFO::getGlobalBounds() {
return ufo.getGlobalBounds();
}
bool UFO::isOnScreen(sf::RenderWindow& window) {
if (getX() >= window.getSize().x || getX() <= window.getSize().x * 0) {
return false;
}
return true;
}