#include <iostream>
#include "gotoxy.h"
#include "conio.h"
#define UP 80
#define DOWN 72
#define RIGTH 77 //derecha
#define LEFT 75 //
class barra{
int x,y,c;
public:
barra():x(10),y(12),c(219){};
void pintar(){
gotoxy(x,y);cout<<(char)c;
}
void borrar(){
gotoxy(x,y);cout<<' ';
}
void mover(){
while(1){
if(kbhit()){
borrar();
char tecla=getch();
switch (tecla){
case UP:
y++;
break;
case DOWN:
y--;
break;
case RIGTH:
x++;
break;
case LEFT:
x--;
break;
}
pintar();
}
}
}
};
using namespace std;
int main()
{
barra bar;
bar.pintar();
bar.mover();
}
#include "gotoxy.h"
#include "conio.h"
#define UP 80
#define DOWN 72
#define RIGTH 77 //derecha
#define LEFT 75 //
class barra{
int x,y,c;
public:
barra():x(10),y(12),c(219){};
void pintar(){
gotoxy(x,y);cout<<(char)c;
}
void borrar(){
gotoxy(x,y);cout<<' ';
}
void mover(){
while(1){
if(kbhit()){
borrar();
char tecla=getch();
switch (tecla){
case UP:
y++;
break;
case DOWN:
y--;
break;
case RIGTH:
x++;
break;
case LEFT:
x--;
break;
}
pintar();
}
}
}
};
using namespace std;
int main()
{
barra bar;
bar.pintar();
bar.mover();
}
Comentarios
Publicar un comentario