#include <TVout.h>
#include <TVoutfonts/fontALL.h>
#include "map.h"
#include "constants.h"
#include "utils.h"
bool newMap;
int width;
int lenght;
int x;
int y;
float radius;
int circleTime;
int circleBlinkQtd;
int sizeImage;
TVout tv;
void setup() {
catImg();
configure_libraries();
lenght = 20;
width = 14;
x = 30;
y = 25;
radius = 10;
circleTime = 300;
circleBlinkQtd = 3;
//start_screen();
newMap = false;
// tv.print(65, 40, "Press any key");
}
void catImg()
{
PROGMEM const char _cat[] = {
lenght,width,
0x04,0x20,0x20,
0x0A,0x50,0x50,
0x11,0x5F,0xD0,
0x20,0xC0,0x10,
0x30,0xC0,0x10,
0x8C,0x48,0x50,
0x62,0x48,0x50,
0x1F,0xC3,0x10,
0x02,0x30,0x60,
0x02,0x08,0x80,
0x02,0x00,0xE0,
0x0F,0x81,0x00,
0x00,0xFF,0xC0,
0x07,0x00,0x00
};
}
void loop() {
draw_image(x, y, _map);
digitalWrite(ACTION, LOW);
//Serial.print(digitalRead(ACTION));
delay(50);
if(digitalRead(ACTION) == HIGH)
{
detect_character(x,y,radius,circleTime,circleBlinkQtd);
}
// put your main code here, to run repeatedly:
}
void detect_character(int positionX,int positionY,float circleRadius, int circleTime, int circleBlinkQtd)
{
//size_image();
for(int i = 0; i < circleBlinkQtd; i++)
{
tv.clear_screen();
delay(circleTime);
tv.draw_circle(positionX, positionY, circleRadius, 1, -1);
delay(circleTime);
}
tv.clear_screen();
}
void size_image()
{
//sizeImage = sizeof(_map);
//Serial.print(sizeImage);
}
void draw_image(int positionX, int positionY, char hexImg)
{
tv.bitmap(positionX, positionY, hexImg);
}
void run() {
}
void start_screen() {
show_text(tv, SCREEN_WIDTH / 4, SCREEN_HEIGHT - 80, "Game name");
show_text(tv, SCREEN_WIDTH / 3, SCREEN_HEIGHT - 40, "Play");
show_text(tv, 10, SCREEN_HEIGHT - 10, "By Astha", font4x6);
show_text(tv, SCREEN_WIDTH - 50, SCREEN_HEIGHT - 10, "FATEC 2022", font4x6);
}
void configure_buttons() {
pinMode(RIGHT_MOVEMENT, INPUT_PULLUP);
pinMode(LEFT_MOVEMENT, INPUT_PULLUP);
pinMode(UP_MOVEMENT, INPUT_PULLUP);
pinMode(DOWN_MOVEMENT, INPUT_PULLUP);
pinMode(ACTION, INPUT_PULLUP);
}
void configure_libraries() {
tv.begin(NTSC, SCREEN_WIDTH, SCREEN_HEIGHT);
}
void configure_screen() {
}