diff --git a/arduino_pong.ino b/arduino_pong.ino index bb2fba7..91b637f 100644 --- a/arduino_pong.ino +++ b/arduino_pong.ino @@ -36,9 +36,9 @@ enum game_statuses : uint8_t { game_statuses game_status= TIMER; Ball ball(4, 6); -// HumanPaddle p1(1, P1_BTN_UP, P1_BTN_BOTTOM); +HumanPaddle p1(1, P1_BTN_UP, P1_BTN_BOTTOM); // HumanPaddle p2(4, P2_BTN_UP, P2_BTN_BOTTOM); -BotPaddle p1(1, 0, 2); +// BotPaddle p1(1, 0, 2); BotPaddle p2(4, MATRIX_WIDTH-1, 1); Engine engine(p1, p2, ball, INITIAL_BALL_DELAY); Renderer renderer(p1, p2, ball, frame, matrix); diff --git a/src/ball.cpp b/src/ball.cpp index b3e1d91..6148a81 100644 --- a/src/ball.cpp +++ b/src/ball.cpp @@ -36,7 +36,9 @@ int8_t Ball::get_direction_y() { void Ball::reset_position () { _x= BALL_RESET_X; - _y= BALL_RESET_Y; + int8_t delta= random(3); + if (random(2) == 0) delta *= -1; + _y= BALL_RESET_Y + delta; this -> _init_directions(_direction_x); this -> _init_directions(_direction_y); } diff --git a/src/engine.cpp b/src/engine.cpp index 19250e9..4d4cef2 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -64,9 +64,9 @@ bool Engine::control_players() { bool need_refresh= false; if (_p1.is_human()) need_refresh |= _p1.check_pad_movement(); - else need_refresh |= _p1.check_pad_movement(); + else need_refresh |= _p1.check_pad_movement(_ball); if (_p2.is_human()) need_refresh |= _p2.check_pad_movement(); - else need_refresh |= _p2.check_pad_movement(); + else need_refresh |= _p2.check_pad_movement(_ball); return need_refresh; }