#include "button.h"
Button up(2);
Button right(3);
Button down(4);
Button left(5);
#include "GyverMAX7219.h"
MAX7219 < 4, 2, 6 > mtrx;
#define WW 10
#define HH 16
#include "tetris.h"
Tetris<WW, HH> mvr;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
mtrx.setFlip(1, 0);
mtrx.begin();
mvr.attachUpd(update);
mvr.attachSet(set);
mvr.attachGameOver(gover);
mvr.newGame();
}
void set(uint8_t x, uint8_t y, uint8_t t) {
mtrx.dot(x, y, t);
}
void gover() {
Serial.println(mvr.score());
mvr.newGame();
}
void update() {
mtrx.update();return;
for (int y = 0; y < HH; y++) {
for (int x = 0; x < WW; x++) {
Serial.print(mvr.get(x, y));
//if (mvr.get(x, y) == 0) Serial.print("⬜");
//else Serial.print("⬛");
}
Serial.println();
}
Serial.println();
}
void loop() {
if (up.click()) mvr.up();
if (right.click()) mvr.right();
if (down.click()) mvr.down();
if (left.click()) mvr.left();
mvr.tick();
delay(1);
}
/*
#include "snake.h"
Snake<32, 16> mvr;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
mtrx.setFlip(1, 0);
mtrx.begin();
mvr.attachUpd(update);
mvr.attachSet(set);
mvr.attachGameOver(gover);
mvr.newGame();
}
void set(uint8_t x, uint8_t y, uint8_t t) {
mtrx.dot(x, y, t);
}
void gover() {
Serial.println(mvr.score());
mvr.newGame();
}
void update() {
mtrx.update();return;
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 32; x++) {
//Serial.print(mvr.get(x, y));
if (mvr.get(x, y) == 0) Serial.print("⬜");
else Serial.print("⬛");
}
Serial.println();
}
Serial.println();
}
void loop() {
if (up.click()) mvr.up();
if (right.click()) mvr.right();
if (down.click()) mvr.down();
if (left.click()) mvr.left();
mvr.tick();
delay(1);
}
*/
#define WW 9
#define HH 9
//#include "mover.h"
//Mover<WW, HH> mvr;
/*#include "maze.h"
Maze<WW, HH> mvr;
void setup() {
Serial.begin(115200);
randomSeed(analogRead(0));
mtrx.setFlip(1, 0);
mtrx.begin();
//mvr.setFOV(3);
mvr.setGamemode(1);
mvr.attachUpd(update);
mvr.attachSet(set);
mvr.attachGameOver(gover);
mvr.newGame();
}
void set(uint8_t x, uint8_t y, uint8_t t) {
mtrx.dot(x, y, t);
}
void gover() {
Serial.println(mvr.score());
mvr.newGame();
}
void update() {
mtrx.update();
for (int y = 0; y < HH; y++) {
for (int x = 0; x < WW; x++) {
//Serial.print(mvr.get(x, y));
if (mvr.get(x, y) == 0) Serial.print("⬜");
else Serial.print("⬛");
}
Serial.println();
}
Serial.println();
}
void loop() {
if (up.click()) mvr.up();
if (right.click()) mvr.right();
if (down.click()) mvr.down();
if (left.click()) mvr.left();
delay(1);
}
*/