#include <MD_MAX72xx.h>
#define HARDWARE_TYPE MD_MAX72XX::DR0CR0RR1_HW
int dataPin = 11;
int clkPin = 13;
int csPin = 10;

int HORZ = A0;
int VERT = A1;
int SELE = 12;
int y = 0;
int x = 0;
int sel = 0;
int hor = 0;
int ver = 0;
int matriz [8][8];
int randomMinaX = random(0, 8);
int randomMinaY = random(0, 8);
MD_MAX72XX matrix = MD_MAX72XX (HARDWARE_TYPE, dataPin, clkPin, csPin, 1);


void setup(){
  pinMode(VERT, INPUT);
  pinMode(HORZ, INPUT);
  pinMode(SELE, INPUT_PULLUP);
  matrix.begin();
  for (int filas = 0; filas < 8; filas++){
    for (int columnas = 0; columnas < 8; columnas++){
      matriz[filas][columnas] = 0;
    }
  }
}

void loop(){
  
  ver = analogRead(VERT);
  hor = analogRead(HORZ);
  sel = digitalRead(SELE);
  if (digitalRead(SELE)== LOW){
  matriz[randomMinaX][randomMinaY] = -1;   
  }
      
  if (ver < 200){
    y++;
      if (y < 0){
      y = 0;
    }
  }

  if (ver > 900){
    y--;
   if (y > 7){
      y = 7;
    }  
  }

  if (hor < 200){
    x--;
     if (x < 0){
       x = 0;
    }
  }

  if (hor > 900){
    x++;
    if (x > 7){
       x = 7;
    }  
  }

  matrix.setPoint(x, y, true);

  delay(100);
}