total reframe with classes
This commit is contained in:
33
src/engine.h
Normal file
33
src/engine.h
Normal 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
|
||||
Reference in New Issue
Block a user