I'm doing a project for the school that consists of drawing a picture using gotoxy and printing asterisks; The fact is that this box has to be moved if I press the arrow keys. I already managed to make the painting move, the problem is that it leaves a trace when moving and it constantly flashes, that happens with any text that it puts. My question is, how do I avoid blinking? It looks very ugly.
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#define derecha 77
#define izquierda 75
#define abajo 80
#define arriba 72
#include<iostream>
using namespace std;
void gotoxy(int x, int y)
{
COORD pos = {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
int i,j,x,y,m=0,n=0;
x=10;
y = 10;
bool fin = false;
char tecla;
while(!fin)
{
if(kbhit())
{
tecla = getch();
if(tecla == derecha)m++;
if(tecla == arriba) n--;
if(tecla == abajo) n++;
if(tecla == izquierda) m--;
for(i=0+x; i<=6+x;i++)//cuadro
{
for(j=1+y; j<=3+y; j++)
{
gotoxy(i+m,j+n);
printf("+");
}
}
gotoxy(20,2); printf("presiona las flechas para mover el teclado");
}
}
}