-
Notifications
You must be signed in to change notification settings - Fork 0
/
Paddle.cpp
57 lines (47 loc) · 972 Bytes
/
Paddle.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
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by vvberaldo on 03/11/24.
//
#include "Paddle.h"
void Paddle::Draw() const {
DrawRectangle(x, y, width, height, WHITE);
}
void Paddle::setSize(const float width, const float height) {
this->width = width;
this->height = height;
}
void Paddle::setPosition(const float x, const float y) {
this->x = x;
this->y = y;
}
float Paddle::getWidth() const {
return width;
}
float Paddle::getHeight() const {
return height;
}
float Paddle::getX() const {
return x;
}
float Paddle::getY() const {
return y;
}
void Paddle::setSpeed(const int speed) {
this->speed = speed;
}
void Paddle::Update() {
if (IsKeyDown(KEY_UP)) {
y = y - speed;
}
if (IsKeyDown(KEY_DOWN)) {
y = y + speed;
}
limitMovement();
}
void Paddle::limitMovement() {
if(y <= 0) {
y=0;
}
if(y + height >= GetScreenHeight()) {
y = GetScreenHeight() - height;
}
}