C++Guns – RoboBlog

25.11.2010

C gotoxy Konsole & ASCII Bildschirmschoner

Filed under: Allgemein — Tags: — Thomas @ 21:11

Möchte man ohne zusätzliche Libs den Cursor auf der Konsole frei bewegen, langt folgender kleiner Hack den man sich schnell aus dem Internet googelt.

Und schwubs di wupp war ein kleiner ASCII Bildschirmschoner hingezaubert.

#include < stdio.h >

void gotoxy(int x,int y)
{
  printf("%c[%d;%df",0x1B,y,x);
}

int main()
{
  int x = 0, y = 0;
  char c = 0;
  system("clear");

  while(1)
  {
    x = rand()%50;
    y = rand()%25;
    c = rand()%'z' + ' ';
    gotoxy(x,y);
    printf("%c", c);
    fflush(stdout);
    sleep(1);
  }
}

Und so schaut er aus

a  avD F        !    ` U /v   y'   z    Y y  j 5
 j   >         \            X         t
S     9                          e o          X
    R x              m    q            P c   E  >
-        7r .   =,  7          l       1
  r           m      e       c#     x     ]   "
         t  B       W  b          V
      G       l  m V  OO        zd
&   7        rX@"  >     dJ          3 )
h    &        H           R    F         3
   !    l   n     6 K m         #     @  u
        h  # |      O               ,    &
j  J        *   P     r c  E /      $
         S       \     S      ^  j5S%f          c
                         p     z_z l           n
               R        f       N   ;  7  q    0
     J   i&     H|   ?    *        y  I      s
a  |     #    Q   5   g\      D   F       e Ho
  f b  ]            

	

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress