-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBat.cpp
More file actions
53 lines (43 loc) · 770 Bytes
/
Copy pathBat.cpp
File metadata and controls
53 lines (43 loc) · 770 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
48
49
50
51
52
53
#include "Bat.hpp"
// Bat constructor, takes in the starting x and y position and positions the bat there
Bat::Bat(float startX, float startY) : _position(startX, startY)
{
_shape.setSize(sf::Vector2f(150, 5));
_shape.setPosition(_position);
}
FloatRect Bat::getPosition()
{
return _shape.getGlobalBounds();
}
RectangleShape Bat::getShape()
{
return _shape;
}
void Bat::moveLeft()
{
_isMovingLeft = true;
}
void Bat::moveRight()
{
_isMovingRight = true;
}
void Bat::stopLeft()
{
_isMovingLeft = false;
}
void Bat::stopRight()
{
_isMovingRight = false;
}
void Bat::update(Time dt)
{
if (_isMovingLeft)
{
_position.x -= _speed * dt.asSeconds();
}
if (_isMovingRight)
{
_position.x += _speed * dt.asSeconds();
}
_shape.setPosition(_position);
}