-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBat.cpp
More file actions
38 lines (30 loc) · 652 Bytes
/
Copy pathBat.cpp
File metadata and controls
38 lines (30 loc) · 652 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
#include "Bat.h"
#include "main.h"
Bat::Bat(float startX, float startY) {
position.x = startX;
position.y = startY;
batShape.setSize(sf::Vector2f(100, 10));
batShape.setPosition(position);
}
FloatRect Bat::getPosition() {
return batShape.getGlobalBounds();
}
RectangleShape Bat::getShape() {
return batShape;
}
void Bat::moveLeft() {
if (position.x > 0) {
position.x -= batSpeed;
}
}
void Bat::moveRight() {
if (position.x + 100 < windowWidth) {
position.x += batSpeed;
}
}
void Bat::reset() {
position.x = windowWidth / 2;
}
void Bat::update() {
batShape.setPosition(position);
}