Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * mijn_source.c
- *
- * Created on: Apr 21, 2011
- * Author: petervanvliet
- */
- #include "mijn_header.h"
- int i = 0;
- int pos_x = 0;
- int pos_y = 0;
- int color = 31;
- char text[] = "Hello World";
- int lengte;
- int a = 0;
- int b = 0;
- int c = 0;
- bool links = true;
- int kolom = 32;
- void print_hello_world()
- {
- iprintf("\x1b[%im", 32);
- iprintf("Hello World!");
- }
- void random_hello_world()
- {
- pos_x = rand() % 15;
- pos_y = rand() % 10;
- color = rand() % 7 + 31;
- iprintf("\x1b[2J"); // Clear screen
- iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
- iprintf("\x1b[%im", color); // Set graphics
- iprintf("Hello World"); // Print text
- for (i = 0; i < 50; i++)
- {
- swiWaitForVBlank();
- }
- }
- void een_voor_een()
- {
- pos_x = rand() % 15;
- pos_y = rand() % 10;
- color = rand() % 7 + 31;
- lengte = (int) strlen(text);
- iprintf("\x1b[2J"); // Clear screen
- iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
- iprintf("\x1b[%im", color); // Set graphics
- for (a = 0; a < lengte; a++)
- {
- color = rand() % 7 + 31;
- iprintf("\x1b[%im", color); // Set graphics
- iprintf("%c", text[a]); // Print text
- for (i = 0; i < 25; i++)
- {
- swiWaitForVBlank();
- }
- if (a == lengte - 1)
- {
- // usleep(10000); werkt niet helaas
- for (i = 0; i < 300; i++)
- {
- swiWaitForVBlank(); // dus gewoon even 500x op een nieuw frame wachten ;)
- }
- }
- }
- }
- void scroll_links_rechts()
- {
- // pos_x = rand() % 15;
- // pos_y = rand() % 10;
- color = rand() % 7 + 31;
- lengte = (int) strlen(text);
- iprintf("\x1b[2J"); // Clear screen
- iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
- iprintf("\x1b[%im", color); // Set graphics
- iprintf("%s", text); // Print text
- if (links)
- {
- for (a = pos_y; a > 0; a--)
- {
- pos_y--;
- if (pos_y <= 0)
- {
- links = false;
- }
- iprintf("\x1b[2J"); // Clear screen
- iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
- iprintf("%s", text); // Print text
- for (i = 0; i < 10; i++)
- {
- swiWaitForVBlank();
- }
- }
- }
- else if (!links)
- {
- for (a = pos_y; a < (kolom-lengte); a++)
- {
- pos_y++;
- if (pos_y >= (kolom-lengte))
- {
- links = true;
- }
- iprintf("\x1b[2J"); // Clear screen
- iprintf("\x1b[%i;%iH", pos_x, pos_y); // Set pos
- iprintf("%s", text); // Print text
- for (i = 0; i < 10; i++)
- {
- swiWaitForVBlank();
- }
- }
- }
- }
- void beweeg()
- {
- }
- void loop()
- {
- while (1)
- {
- // een_voor_een();
- // beweeg();
- scroll_links_rechts();
- }
- }
- int main()
- {
- pos_x = rand() % 15;
- pos_y = rand() % 10;
- consoleDemoInit();
- loop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment