-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.cpp
55 lines (42 loc) · 929 Bytes
/
GameObject.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
47
48
49
50
51
52
53
54
55
#include <SFML/Graphics.hpp>
#include <iostream>
#include "GameObject.hpp"
GameObject::GameObject() {
isLoaded = false;
}
GameObject::~GameObject() {
}
bool GameObject::IsLoaded() {
return isLoaded;
}
void GameObject::Load(std::string filename) {
if (!texture.loadFromFile(filename)) {
isLoaded = false;
} else {
isLoaded = true;
}
if (isLoaded) {
texture.setSmooth(true);
sprite.setTexture(texture);
}
}
void GameObject::SetPosition(float x, float y) {
if (isLoaded)
sprite.setPosition(x, y);
}
void GameObject::SetRotation(float r) {
if (isLoaded)
sprite.setRotation(r);
}
sf::FloatRect GameObject::GetBounds() {
return sprite.getGlobalBounds();
}
sf::Sprite& GameObject::GetSprite() {
return sprite;
}
void GameObject::Update(sf::Time elapsed) { }
void GameObject::HandleCollision(sf::FloatRect) { }
void GameObject::Draw(sf::RenderWindow& window) {
if (isLoaded)
window.draw(sprite);
}