From c85889e2d2c15e8166435b376bf36367a28ca844 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 6 Nov 2011 19:31:22 +0100 Subject: schnecke mit fading --- Matrix_5x6/Charlie/Charlie.pde | 73 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 6 deletions(-) (limited to 'Matrix_5x6/Charlie') diff --git a/Matrix_5x6/Charlie/Charlie.pde b/Matrix_5x6/Charlie/Charlie.pde index ee7f5dd..d863a03 100644 --- a/Matrix_5x6/Charlie/Charlie.pde +++ b/Matrix_5x6/Charlie/Charlie.pde @@ -57,12 +57,14 @@ int aus = 10; void setup(){ /*nothing*/ } -void zufall_fading() { +/* zufällige LEDs werden langsam dunkler */ + +void zufall_fading_down() { clrscr(); int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) - scr[x][y] = random(30) + 2; + scr[x][y] = random(30); int i=30; @@ -73,12 +75,14 @@ void zufall_fading() { } -void zufall_fading2() { +/* zufällige LEDs werden langsam heller */ + +void zufall_fading_up() { clrscr(); int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) - scr[x][y] = - random(30) - 2; + scr[x][y] = - random(30); int i=50; @@ -86,10 +90,67 @@ void zufall_fading2() { drawscr(2); fadescr_up(); } +} - +/* schnecke mit vier startpunkten (0 bis 3) von außen nach innnen + mit fading */ + +void schnecke(int s) { + clrscr(); + int x, y, d, w = 0; + d = s; + switch(s) { + case 0: + x = 0; + y = 0; + break; + case 1: + x = 5; + y = 0; + break; + case 2: + x = 5; + y = 4; + break; + case 3: + x = 0; + y = 4; + break; + } + + while (1) { + if (scr[x][y]) break; + + scr[x][y] = 20; + drawscr(2); + fadescr_down(); + + switch (d) { + case 0: if (x == 5 - w) {d = 1; if (s == 2) w++;} break; + case 1: if (y == 4 - w) {d = 2; if (s == 3) w++;} break; + case 2: if (x == w) {d = 3; if (s == 0) w++;} break; + case 3: if (y == w) {d = 0; if (s == 1) w++;} break; + } + + switch (d) { + case 0: x++; break; + case 1: y++; break; + case 2: x--; break; + case 3: y--; break; + } + } + int i = 20; + while(i--) { + fadescr_down(); + drawscr(2); + } } void loop() { - zufall_fading2(); +// zufall_fading_up(); +// zufall_fading_down(); + schnecke(0); + schnecke(1); + schnecke(2); + schnecke(3); } -- cgit v1.2.3