total reframe with classes

This commit is contained in:
andrea
2026-03-17 23:25:30 +01:00
parent d8efabd6da
commit 3d8881ab3d
14 changed files with 246 additions and 319 deletions

33
src/engine.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef ENGINE_H
#define ENGINE_H
#include <Arduino.h>
#include "ball.h"
#include "paddle.h"
#include "config.h"
enum EngineEvents : uint8_t {NONE, P1SCORE, P2SCORE, P1_COLLISION, P2_COLLISION, WALL_COLLISION};
class Engine {
private:
Paddle& _p1;
Paddle& _p2;
Ball& _ball;
uint8_t _hits;
EngineEvents _event= NONE;
bool _check_pad_ball_collision(Paddle &p);
void _print_score();
public:
// inizialize Engine constructor, linking all args with private args
Engine(Paddle &p_one, Paddle &p_two, Ball &ball)
: _p1(p_one), _p2(p_two), _ball(ball) {}
void run(uint8_t &ball_delay);
EngineEvents get_event();
void reset();
};
#endif