2026-03-17 23:25:30 +01:00
|
|
|
#ifndef BALL_H
|
|
|
|
|
#define BALL_H
|
2026-03-17 20:11:21 +01:00
|
|
|
|
2026-03-18 21:41:51 +01:00
|
|
|
#include <Arduino.h>
|
2026-03-17 20:11:21 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
class Ball {
|
|
|
|
|
private:
|
|
|
|
|
uint8_t _x, _y;
|
|
|
|
|
int8_t _direction_x, _direction_y;
|
|
|
|
|
|
2026-03-17 23:25:30 +01:00
|
|
|
void _init_directions(int8_t &_direction);
|
|
|
|
|
|
2026-03-17 20:11:21 +01:00
|
|
|
public:
|
2026-03-17 23:25:30 +01:00
|
|
|
Ball (uint8_t _x, uint8_t _y) : _x(_x), _y(_y) {}
|
|
|
|
|
|
2026-03-17 20:11:21 +01:00
|
|
|
void move();
|
|
|
|
|
void bounce_on_pad();
|
|
|
|
|
void bounce_on_sides();
|
2026-03-18 21:41:51 +01:00
|
|
|
int8_t get_direction_x();
|
|
|
|
|
int8_t get_direction_y();
|
2026-03-17 20:11:21 +01:00
|
|
|
void reset_position ();
|
|
|
|
|
uint8_t get_x();
|
|
|
|
|
uint8_t get_y();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|