diff --git a/src/main.cpp b/src/main.cpp index dfd6804..e450a9e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,10 +25,20 @@ RST = Reset - 10K to GND, 10uF to VCC XTAL = 16 MHz Crystal IN = switches MIC = Input from microphone amplifier (LM358) - - */ +/* + x + XXXXXXX + XX XXX XX +XXXXXXXXXXX +X XXXXXXX X +X X X X + XX XX +*/ + +byte invaderA_1[11] = {112,24,125,182,188,60,188,182,125,24,112}; + #define LATCHPIN 5 #define DATAPIN 4 #define CLOCKPIN 6 @@ -75,13 +85,36 @@ void setup() { pushout(); } +void drawinvader(int xposition, int yposition) { + // TODO yposition + + for (int x=0; x<=11; x++) { + int screenx = x+xposition; + if (screenx >=0 && screenx < 8) { + for (int y=0; y<8; y++) { + int screeny = y+yposition; + if (screeny >=0 && screeny < 8) { + if (bitRead(invaderA_1[x],y) == HIGH ) { + writexy(screenx,screeny); + } + } + } + } + } +} + byte currentcol=1; bool direction = true; +int invaderstart = -12; +int invaderend = 8; +int invaderposition = invaderstart; + void loop() { clear(); + /* // x-line for(byte i=0; i<8; i++) { writexy(i,currentcol-1); @@ -90,9 +123,18 @@ void loop() { for(byte i=0; i<8; i++) { writexy(currentcol-1,i); } + */ + + drawinvader(invaderposition,0); + + invaderposition++; + if (invaderposition >=invaderend) { + invaderposition = invaderstart; + } pushout(); +/* if(direction) { currentcol++; } else { @@ -106,5 +148,6 @@ void loop() { currentcol=2; direction = true; } - delay(100); + */ + delay(300); }