start refactoring pong entities to use classes

This commit is contained in:
andrea
2026-03-17 20:11:21 +01:00
parent c774e11923
commit d8efabd6da
5 changed files with 194 additions and 0 deletions

32
src/paddle.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <stdint.h>
#include "config.h"
class Paddle {
private:
// define player coordinates
uint8_t _position, _height;
bool _human;
public:
void move_pad_up(bool &need_refresh) {
if (_position > 0) {
_position -= 1;
need_refresh= true;
}
}
void move_pad_down(bool &need_refresh) {
if (_position + _height <= MATRIX_HEIGHT) {
_position += 1;
need_refresh= true;
}
}
uint8_t get_position() {
return _position;
}
bool is_human() {
return _human;
}
};