first invader

This commit is contained in:
robelix 2018-01-14 22:21:27 +01:00
parent ef8db2deba
commit ac8a575227

View file

@ -25,10 +25,20 @@ RST = Reset - 10K to GND, 10uF to VCC
XTAL = 16 MHz Crystal XTAL = 16 MHz Crystal
IN = switches IN = switches
MIC = Input from microphone amplifier (LM358) 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 LATCHPIN 5
#define DATAPIN 4 #define DATAPIN 4
#define CLOCKPIN 6 #define CLOCKPIN 6
@ -75,13 +85,36 @@ void setup() {
pushout(); 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; byte currentcol=1;
bool direction = true; bool direction = true;
int invaderstart = -12;
int invaderend = 8;
int invaderposition = invaderstart;
void loop() { void loop() {
clear(); clear();
/*
// x-line // x-line
for(byte i=0; i<8; i++) { for(byte i=0; i<8; i++) {
writexy(i,currentcol-1); writexy(i,currentcol-1);
@ -90,9 +123,18 @@ void loop() {
for(byte i=0; i<8; i++) { for(byte i=0; i<8; i++) {
writexy(currentcol-1,i); writexy(currentcol-1,i);
} }
*/
drawinvader(invaderposition,0);
invaderposition++;
if (invaderposition >=invaderend) {
invaderposition = invaderstart;
}
pushout(); pushout();
/*
if(direction) { if(direction) {
currentcol++; currentcol++;
} else { } else {
@ -106,5 +148,6 @@ void loop() {
currentcol=2; currentcol=2;
direction = true; direction = true;
} }
delay(100); */
delay(300);
} }