Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <curses.h>
- using namespace std;
- WINDOW *win;
- void IniVideo(){
- win=initscr();
- clear();
- refresh();
- noecho();
- cbreak();
- keypad(win, TRUE);
- curs_set(0);//No hay cursor
- }
- void Exit(){
- refresh();
- endwin();
- exit(1);
- }
- int main () {
- int x(0);int y(0);
- int MAXY(0);int MAXX(0);
- int tecla(0);
- IniVideo();
- nodelay(stdscr, TRUE);
- getmaxyx(win, MAXY,MAXX);// to get the size of
- while (true){
- //move(12, 30); /* x , y */
- tecla=getch();
- if (tecla=='a'){x--;}
- if (tecla=='z'){x++;}
- if (tecla=='q'){y--;}
- if (tecla=='w'){y++;}
- if (x<0){x=MAXX-1;}
- if (y<0){y=MAXY-1;}
- if (x>MAXX-1){x=1;}
- if (y>MAXY-1){y=1;}
- clear();
- wmove(win, y, x);
- printw("x");
- //refresh();
- wrefresh(win);
- }
- Exit();
- }
Add Comment
Please, Sign In to add comment