aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jetris.ino10
-rw-r--r--sprites.h94
-rw-r--r--tags2
3 files changed, 102 insertions, 4 deletions
diff --git a/Jetris.ino b/Jetris.ino
index 970ada2..8496f59 100644
--- a/Jetris.ino
+++ b/Jetris.ino
@@ -48,16 +48,18 @@ int ballYv = 1;
int last = 0;
-Sprite *logo = &ball;
+Sprite *logo = blocks[4];
void loop() {
delay(100);
-
+
if(ballX + ballXv + logo->width > 8 || ballX + ballXv < 0){
ballXv = -ballXv;
+ logo = blocks[random(7)];
}
if(ballY + ballYv + logo->height > 16 || ballY + ballYv < 0){
ballYv = -ballYv;
+ logo = blocks[random(7)];
}
ballX += ballXv;
@@ -107,7 +109,7 @@ void initDisplay() {
writeCommand(maxSHUTDOWN_INV, 1);
//Darker please
- writeCommand(maxINTENSITY, 0x00);
+ writeCommand(maxINTENSITY, 0x01);
//Activate all lines
writeCommand(maxSCAN_LIMIT, 0x07);
@@ -171,8 +173,8 @@ void drawRegion(uint8_t xMask, uint16_t yMask, bool state) {
}
void render(uint8_t buffer[]) {
- for(int i = 0; i < 8; i++ ) {
+ for(int i = 0; i < 8; i++ ) {
writeCommand(maxDIGIT_0 + i, buffer[i]);
}
diff --git a/sprites.h b/sprites.h
index 5aceee4..3b53d47 100644
--- a/sprites.h
+++ b/sprites.h
@@ -59,4 +59,98 @@ const Sprite miniSmiley = {
}, 4, 3
};
+
+const Sprite iBlock = {
+ {
+ 0b11110000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 4, 1
+};
+
+const Sprite oBlock = {
+ {
+ 0b11000000,
+ 0b11000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 2, 2
+};
+
+const Sprite tBlock = {
+ {
+ 0b01000000,
+ 0b11100000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 3, 2
+};
+
+const Sprite sBlock = {
+ {
+ 0b01100000,
+ 0b11000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 3, 2
+};
+
+const Sprite zBlock = {
+ {
+ 0b11000000,
+ 0b01100000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 3, 2
+};
+
+const Sprite jBlock = {
+ {
+ 0b10000000,
+ 0b11100000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 3, 2
+};
+
+const Sprite lBlock = {
+ {
+ 0b00100000,
+ 0b11100000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000,
+ 0b00000000
+ }, 3, 2
+};
+
+const Sprite *blocks[] = { &iBlock, &oBlock, &tBlock, &sBlock, &zBlock, &jBlock, &lBlock };
+
#endif
diff --git a/tags b/tags
index 458c10e..c45c520 100644
--- a/tags
+++ b/tags
@@ -6,6 +6,7 @@
!_TAG_PROGRAM_VERSION 5.8 //
MaxCommands MaxCommands.h 2;" d
Sprite sprites.h /^struct Sprite {$/;" s
+ball sprites.h /^const Sprite ball = {$/;" v
buff sprites.h /^ uint8_t buff[8];$/;" m struct:Sprite
checker sprites.h /^const Sprite checker = {$/;" v
height sprites.h /^ uint8_t height;$/;" m struct:Sprite
@@ -22,6 +23,7 @@ maxINTENSITY MaxCommands.h 6;" d
maxSCAN_LIMIT MaxCommands.h 16;" d
maxSHUTDOWN_INV MaxCommands.h 4;" d
maxTEST MaxCommands.h 5;" d
+miniSmiley sprites.h /^const Sprite miniSmiley = {$/;" v
smiley sprites.h /^const Sprite smiley = { $/;" v
sprites sprites.h 2;" d
width sprites.h /^ uint8_t width;$/;" m struct:Sprite