-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
65 lines (51 loc) · 1.49 KB
/
Copy pathPlayer.cpp
File metadata and controls
65 lines (51 loc) · 1.49 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
52
53
54
55
56
57
58
59
60
61
62
#include "Player.h"
void Player::initAnimationComponent()
{
this->animation = new Animation(this->texture, Vector2u(4, 4), 0.2f);
}
void Player::initTexture()
{
if (!this->texture->loadFromFile("content/Textures/Character.png"))
{
cout << "ERROR::PLAYER::INITTEXTURE::Could not load texture file." << "\n";
}
}
void Player::initVariables()
{
this->points = 0;
}
void Player::initComponents()
{
this->createMovementComponent(50.f);
this->initAnimationComponent();
}
Player::Player(float x, float y, Texture& texture_sheet)
{
this->texture = &texture_sheet;
this->initVariables();
this->initComponents();
this->setTexture(texture_sheet);
this->setpos(x,y);
}
Player::~Player()
{
}
// void Player::upateWindowBoundCollision(RenderWindow* window)
// {
// if (this->sprite->getPosition().x < 0.f)
// {
// this->sprite->setPosition(0.f, this->sprite->getPosition().y);
// }
// else if (this->sprite->getPosition().x + this->sprite->getGlobalBounds().width > window->getSize().x)
// {
// this->sprite->setPosition(window->getSize().x - this->sprite->getGlobalBounds().width, this->sprite->getPosition().y);
// }
// else if (this->sprite->getPosition().y < 0.f)
// {
// this->sprite->setPosition(this->sprite->getPosition().x, 0.f);
// }
// else if (this->sprite->getPosition().y + this->sprite->getGlobalBounds().height > window->getSize().y)
// {
// this->sprite->setPosition(this->sprite->getPosition().x, window->getSize().y - this->sprite->getGlobalBounds().height);
// }
// }