-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBat.cpp
More file actions
47 lines (38 loc) · 659 Bytes
/
Copy pathBat.cpp
File metadata and controls
47 lines (38 loc) · 659 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
46
47
#include "Bat.h"
Bat::Bat(float startX, float startY) : m_Position(startX, startY)
{
m_Shape.setSize(sf::Vector2f(5, 150));
m_Shape.setPosition(m_Position);
}
FloatRect Bat::getPosition()
{
return m_Shape.getGlobalBounds();
}
RectangleShape Bat::getShape()
{
return m_Shape;
}
void Bat::moveUp()
{
m_MovingUp = true;
}
void Bat::moveDown()
{
m_MovingDown = true;
}
void Bat::stopUp()
{
m_MovingUp = false;
}
void Bat::stopDown()
{
m_MovingDown = false;
}
void Bat::update(Time dt)
{
if (m_MovingUp)
m_Position.y -= m_Speed * dt.asSeconds();
if (m_MovingDown)
m_Position.y += m_Speed * dt.asSeconds();
m_Shape.setPosition(m_Position);
}