-
Notifications
You must be signed in to change notification settings - Fork 0
/
Moveable.cpp
46 lines (36 loc) · 949 Bytes
/
Moveable.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
#include "Headers/Moveable.hpp"
Moveable::Moveable(sf::Vector2f position, float const width, float const height)
: Sprite(position, width, height)
{};
Moveable::Moveable(sf::Vector2f position, float const width, float const height, sf::Vector2f velocity)
: Sprite(position, width, height)
, velocity_(velocity)
{};
sf::Vector2f Moveable::getVelocity() const
{
return this-> velocity_;
};
void Moveable::setGravityStatus(bool status)
{
gravityStatus_ = status;
}
void Moveable::setVelocity(sf::Vector2f velocity)
{
velocity_ = velocity;
};
void Moveable::draw(sf::RenderWindow& i_window)
{
rectangle_.setFillColor(sf::Color::Red);
rectangle_.setSize(sf::Vector2f(width_, height_));
rectangle_.setPosition(position_);
i_window.draw(rectangle_);
}
void Moveable::updatePosition()
{
if(gravityStatus_)
{
velocity_.y += gravity_;
}
position_ += velocity_;
updateVertexes();
}