Hello guys !
Until now I always found the answers of my questions on Google, but not today.
So I come here to explain my problem to you.
First my project:
I'm developping a little game (space invader) based on Arduino Uno and a 32x32 LED Matrix.
I've developped a nice first version quickly but not exactly what I expect and bad wrote in C.
So I want to re-write it using the C structure's.
But something curious appear.
It seems the Arduino can't do the job if the code is too "evolved".
I don't have nothing on my matrix screen.
My code below is compiled and uploaded without error but not working.
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
void setup() {
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
matrix.begin();
}
struct Missile{
bool ON;
int PosX = 0;
int PosY = 0;
int Couleur = matrix.Color333(0, 7, 7);
};
struct Missile missileVaisseau, missileMonstre;
struct Vaisseau{
int PosX = 0;
int Couleur1 = matrix.Color333(7, 7, 7);
int Couleur2 = matrix.Color333(7, 0, 0);
Missile missileVaisseau;
};
struct Vaisseau vaisseau;
struct Monstre{
int PosX = 0;
int PosY = 0;
Missile missileMonstre;
};
struct Monstre monstre1, monstre2, monstre3, monstre4, monstre5, monstre6;
void loop() {
spaceship_print(vaisseau.PosX,vaisseau.Couleur1,vaisseau.Couleur2);
delay(500);
}
void spaceship_print(int x, int couleur1, int couleur2){
matrix.drawPixel( 13 + x, 31, couleur1);
matrix.drawPixel( 15 + x, 31, couleur1);
matrix.drawPixel( 17 + x, 31, couleur1);
matrix.drawPixel( 13 + x, 30, couleur1);
matrix.drawPixel( 14 + x, 30, couleur1);
matrix.drawPixel( 15 + x, 30, couleur1);
matrix.drawPixel( 16 + x, 30, couleur1);
matrix.drawPixel( 17 + x, 30, couleur1);
matrix.drawPixel( 14 + x, 29, couleur1);
matrix.drawPixel( 16 + x, 29, couleur1);
matrix.drawPixel( 15 + x, 28, couleur1);
matrix.drawPixel( 15 + x, 29, couleur2);
matrix.drawPixel( 14 + x, 31, couleur2);
matrix.drawPixel( 16 + x, 31, couleur2);
}
That's curious because when I comment this part of the code it's working well, I print a spaceship on my screen, just like I expected.
struct Monstre{
int PosX = 0;
int PosY = 0;
Missile missileMonstre;
};
struct Monstre monstre1, monstre2, monstre3, monstre4, monstre5, monstre6;
Does anybody have already had the same problem ? It's really curious...