Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. /*
  2. TSEA83 PROJECT USER PROGRAM
  3.  
  4. RAINBOW - A program for printing a colorful rainbow
  5. */
  6.  
  7. int rainbow() {
  8.    
  9.     int index = 0;
  10.     int color = 0;
  11.     char keyboard = 0;
  12.     char goodbyee[] = "GOODBYE";
  13.     while(1) {
  14.         // Drawing loop
  15.         index = 0;
  16.         out(index 0);
  17.         while(index < VIDEO_TILES) {
  18.             // Poll for quit
  19.             keyboard = read_char();
  20.             if (keyboard == '\e'){
  21.                 print(goodbyee);
  22.                 sleep_ms(500);
  23.                 return 0;
  24.             }
  25.  
  26.             //Only count the 11 colors
  27.             if (color >= 11) color = 0;
  28.  
  29.             // Set color
  30.             BG_COLOR = 4 + color;
  31.  
  32.             // Output nul character
  33.             print_c(0);
  34.  
  35.             index = index + 1;
  36.             color = color + 1;
  37.             sleep_ms(10);
  38.         }
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement