From ba34771069f48c83aa7611f260a50c4d1e5e909a Mon Sep 17 00:00:00 2001 From: NiciDieNase Date: Thu, 11 Aug 2011 10:51:02 +0200 Subject: [PATCH] Added SpaceInvaders Nick-Animation --- firmware/l0dable/nick_invaders.c | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 firmware/l0dable/nick_invaders.c diff --git a/firmware/l0dable/nick_invaders.c b/firmware/l0dable/nick_invaders.c new file mode 100644 index 0000000..faab749 --- /dev/null +++ b/firmware/l0dable/nick_invaders.c @@ -0,0 +1,80 @@ +/* nick_invaders.c + * + * By NiciDieNase + * r0ket@nicidienase.de + * + * Known Bugs: + * - Ignores Font-Setting + * - might look odd with really short or really long nicknames + * + */ + +#include +#include +#include "basic/basic.h" +#include "lcd/render.h" +#include "lcd/display.h" +#include "usetable.h" +#include "lcd/fonts.h" +#include "lcd/fonts/invaders.h" +#include "lcd/fonts/invaders.c" + +void ram(void) +{ + bool step = true; + const int minX = 10; + const int minY = 10; + const int maxX = 50; + const int maxY = 30; + const int space = 15; + const int delaytime = 150; + const int defaultfont = font; + int x = minX; + int y = minY; + int u = 0; + int dir = 0; + + while(1){ + lcdFill(0); + font = &Font_Invaders; + // Draw UFO + DoChar(-15+u,1,'U'); + u+=2; + if(u > 1337) u=0; + //Draw Invaders + DoChar(x,y,step?'a':'A'); + DoChar(x+space,y,step?'b':'B'); + DoChar(x+2*space,y,step?'c':'C'); + switch (dir){ + // move left + case 0: + x++; + if(x == maxX) dir++; + break; + // move down on right end + case 1: + y++; + dir++; + if(y == maxY) y=minY; + break; + // move left + case 2: + x--; + if(x==minX) dir++; + break; + // move down on left end + case 3: + y++; + dir++; + if(y == maxY) y=minY; + break; + } + dir %= 4; + font = defaultfont; + DoString(10,40,nickname); + lcdDisplay(); + if(getInputRaw()!=BTN_NONE) return; + step = !step; + delayms_queue_plus(delaytime,0); + } +}