#include <FastLED.h>
#include "Global_Setup.h"
#include "Matrix.h"
#include "DButtons.h" // Umbenannt Buttons(orig.) -> DButtons.h
#include "Game.h"
#include "Sprites.h"
//------------------------//
#include "Winehandler.h" // Verwaltet das gesamte Spiel
//#include "Shelf.h" // Objekt für ein (Wein-)Fach (vgl. Zelle)
#include "Joystick.h" // Bündelt Analoge Joysticks in jeweils einem Objekt
#include "Buttons.h" // Bündelt Knöpfe in einem Objekt. Modifizierte Version von DButtons.h
// *** Creating objects ***
// Matrix objectName(fps);
Matrix matrix(25);
// Buttons objectName(firstPin, lastPin, readInterval);
Buttons buttons(4, 5, READ_INTERVAL);
// *** GameObjects & Projectiles ***
// GameObject objectName(name, spriteArray, width, height, xPos, yPos, collisionLayer, visibility, standalone);
// collisionLayer (0-255) -> Higher can collide with lower, equal can't collide
// visibility (optinal, default: false) -> If true, object is visible and will be displayed
// standalone (optional, default: false) -> If true, object is not part of render queue and has to be displayed manually
//GameObject crosshair("Crosshair", crosshairSprite, 3, 3, 0, 0, 100, true, false);
GameObject redPixel("Pixel", redPixelSprite, 1, 1, 15, 15, 111, true, false);
Winehandler Winesweeper;
Joystick joy(VERT_PIN, HORZ_PIN, SEL_PIN, READ_INTERVAL);
void setup() {
Serial.begin(115200);
randomSeed(analogRead(A10));
matrix.init();
buttons.init();
joy.init();
Winesweeper.init();
// Add objects to render queue with matrix.add(&object)
// Remove objects from render queue with matrix.remove(&object)
//matrix.add(&crosshair);
matrix.add(&redPixel);
matrix.printRenderQueue();
// Manually draw object
//matrix.drawObject(&raumschiff);
// Manually erase object
//matrix.eraseObject(&raumschiff);
// Apply leds array to matrix
matrix.show();
// Initialize Joystick Library
/*
for(int i = 0; i <= MATRIX_WIDTH-1; i++) {
for(int j = 0; j <= MATRIX_HEIGHT-1; j++) {
bool value = Winesweeper.getParcel(i, j)->isWine();
Serial.println("i: " + String(i) + " j: " + String(j) + " Wert: " + String(value));
}
}
*/
}
void loop() {
// Global system tick
systemtime = millis();
//bool selPressed = digitalRead(SEL_PIN) == LOW;
// selPressed is true if the joystick is pressed
joy.update();
joy.moveObject(&redPixel);
buttons.update();
//
//
// Global timed rendering with render queue
matrix.update();
}