#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "esp_timer.h"
#define SCREEN_WIDTH 99
#define SCREEN_HEIGHT 50
enum objects_type {
paddle = 0,
ball
};
typedef struct {
uint8_t x;
uint8_t y;
uint8_t object_type;
} objetcts_game;
static objetcts_game objects_coordinates[2];
void gotoxy(int x, int y) {
printf("\033[%d;%dH", y, x);
}
static void display_board() {
while(1) {
printf("\033[2J");
for (int height = 0; height < objects_coordinates[ball].y; height ++) {
printf("\n");
}
for (int width = 0 ; width < objects_coordinates[ball].x; width ++) {
printf(" ");
}
printf("■\n");
printf("\r");
for (int height = objects_coordinates[ball].y; height < SCREEN_HEIGHT; height ++) {
printf("\n");
}
for (int width = 0 ; width < objects_coordinates[paddle].x; width ++) {
printf(" ");
}
printf("-----");
vTaskDelay(100/portTICK_PERIOD_MS);
}
}
void app_main(void)
{
objects_coordinates[ball].x = 50;
objects_coordinates[ball].y = 15;
objects_coordinates[ball].object_type = ball;
objects_coordinates[paddle].x = 48;
objects_coordinates[paddle].y = 50;
objects_coordinates[paddle].object_type = paddle;
xTaskCreate(display_board, "display_board", 2048 , NULL , 1 , NULL);
}