Mattie

Untitled

May 16th, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.62 KB | None | 0 0
  1. /*
  2.  * mijn_source.c
  3.  *
  4.  *  Created on: Apr 21, 2011
  5.  *      Author: petervanvliet
  6.  */
  7.  
  8. #include "mijn_header.h"
  9.  
  10. int i = 0;
  11. int pos_x = 0;
  12. int pos_y = 0;
  13. int color = 31;
  14.  
  15. char text[] = "Hello World";
  16. int lengte;
  17. int a = 0;
  18. int b = 0;
  19. int c = 0;
  20. bool links = true;
  21. int kolom = 32;
  22.  
  23. void print_hello_world()
  24. {
  25.     iprintf("\x1b[%im", 32);
  26.     iprintf("Hello World!");
  27. }
  28.  
  29. void random_hello_world()
  30. {
  31.     pos_x = rand() % 15;
  32.     pos_y = rand() % 10;
  33.     color = rand() % 7 + 31;
  34.  
  35.     iprintf("\x1b[2J"); // Clear screen
  36.     iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
  37.     iprintf("\x1b[%im", color); // Set graphics
  38.     iprintf("Hello World"); // Print text
  39.  
  40.     for (i = 0; i < 50; i++)
  41.     {
  42.         swiWaitForVBlank();
  43.     }
  44. }
  45.  
  46. void een_voor_een()
  47. {
  48.     pos_x = rand() % 15;
  49.     pos_y = rand() % 10;
  50.     color = rand() % 7 + 31;
  51.     lengte = (int) strlen(text);
  52.  
  53.     iprintf("\x1b[2J"); // Clear screen
  54.     iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
  55.     iprintf("\x1b[%im", color); // Set graphics
  56.  
  57.     for (a = 0; a < lengte; a++)
  58.     {
  59.         color = rand() % 7 + 31;
  60.         iprintf("\x1b[%im", color); // Set graphics
  61.         iprintf("%c", text[a]); // Print text
  62.         for (i = 0; i < 25; i++)
  63.         {
  64.             swiWaitForVBlank();
  65.         }
  66.         if (a == lengte - 1)
  67.         {
  68.             //          usleep(10000); werkt niet helaas
  69.             for (i = 0; i < 300; i++)
  70.             {
  71.                 swiWaitForVBlank(); // dus gewoon even 500x op een nieuw frame wachten ;)
  72.             }
  73.         }
  74.     }
  75. }
  76.  
  77. void scroll_links_rechts()
  78. {
  79. //  pos_x = rand() % 15;
  80. //  pos_y = rand() % 10;
  81.     color = rand() % 7 + 31;
  82.     lengte = (int) strlen(text);
  83.  
  84.     iprintf("\x1b[2J"); // Clear screen
  85.     iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
  86.     iprintf("\x1b[%im", color); // Set graphics
  87.     iprintf("%s", text); // Print text
  88.  
  89.  
  90.     if (links)
  91.     {
  92.  
  93.         for (a = pos_y; a > 0; a--)
  94.         {
  95.             pos_y--;
  96.  
  97.             if (pos_y <= 0)
  98.             {
  99.                 links = false;
  100.             }
  101.  
  102.             iprintf("\x1b[2J"); // Clear screen
  103.             iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
  104.             iprintf("%s", text); // Print text
  105.  
  106.             for (i = 0; i < 10; i++)
  107.             {
  108.                 swiWaitForVBlank();
  109.             }
  110.         }
  111.     }
  112.  
  113.     else if (!links)
  114.     {
  115.         for (a = pos_y; a < (kolom-lengte); a++)
  116.         {
  117.             pos_y++;
  118.  
  119.             if (pos_y >= (kolom-lengte))
  120.             {
  121.                 links = true;
  122.             }
  123.  
  124.             iprintf("\x1b[2J"); // Clear screen
  125.             iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
  126.             iprintf("%s", text); // Print text
  127.  
  128.             for (i = 0; i < 10; i++)
  129.             {
  130.                 swiWaitForVBlank();
  131.             }
  132.         }
  133.     }
  134.  
  135. }
  136.  
  137. void beweeg()
  138. {
  139.  
  140. }
  141.  
  142. void loop()
  143. {
  144.     while (1)
  145.     {
  146.         //      een_voor_een();
  147.         //      beweeg();
  148.         scroll_links_rechts();
  149.     }
  150. }
  151.  
  152. int main()
  153. {
  154.     pos_x = rand() % 15;
  155.     pos_y = rand() % 10;
  156.     consoleDemoInit();
  157.     loop();
  158.     return 0;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment