#include <curses.h>
#include <stdlib.h>
/* 'q' */
#define QUIT 113
/* '<-' */
#define LEFT 260
/* -> */
#define RIGHT 261

int main()
{
  int x=40,zufall, c,i,vor,hint;
  srand(79);
  initscr();
  if(has_colors()==TRUE)
     start_color();
  else
     exit (0);
  keypad(stdscr,TRUE);   /*Cursor und Funktionstasten*/

  noecho();   /*keine Ausgabe*/
  scrollok(stdscr,TRUE);   /*Scrolling ein*/
  scroll(stdscr);
  init_pair(1,COLOR_YELLOW,COLOR_BLACK);   /*Farbenpaar Nummer 1*/
  init_pair(2,COLOR_CYAN,COLOR_CYAN);      /*PaarNummer 2*/
  init_pair(3,COLOR_GREEN,COLOR_BLACK);    /*Farbenpaar Nummer 3*/
  init_pair(4,COLOR_BLACK,COLOR_GREEN);    /*Farbenpaar Nummer 4*/
  while(c!=QUIT)
   {
      scrl(1); /*Eine Zeile runter scrollen*/
      for(i=0;i<5;i++)
        {
          zufall=rand()%79;
          attrset(A_DIM|COLOR_PAIR(1));   /*Sterne dunkel ausgegeben*/
          mvaddch(20,zufall,'*');
          attrset(A_UNDERLINE|A_BOLD|COLOR_PAIR(4));   /*Blinkend*/
          mvprintw(0,0,"'q' drücken für Quit | Taste für Start | <- nach links -> nach rechts");
        }

     c=getch();
     halfdelay(3);
     switch(c)
      {
        case LEFT : if(x<1) x=79;
                             else x--;
                             break;
       case RIGHT: if(x>79) x=1;
                             else x++;
                             break;
       default         : break;
     }

    mvdelch(9,x+2);mvdelch(9,x+1);mvdelch(9,x);
    mvdelch(9,x-1);mvdelch(9,x-2);
    attrset(A_BOLD|COLOR_PAIR(2)); /*Raumschiff fette Schrift*/
    mvaddch(10,x-1,ACS_LLCORNER);
    mvaddch(10,x+1,ACS_LRCORNER);
    attrset(A_BOLD|COLOR_PAIR(3));
    mvaddch(10,x,ACS_TTEE);
   }  /*Ende while()*/

  endwin();
  return 0;
}
