#include <avr/pgmspace.h> // librairie pour utiliser la mémoire de stockage pour les grosses variables constantes
#include "rtttl.h"//librairie de gestion de la musique
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
#include "fonctionsObjets.h"
void setup()
{
/*----DEMARRAGE DE L'ECRAN LCD ET DU RETROECLAIRAGE-------------*/
/*----POSITIONNEMENTS ET AFFICHAGES DE DEPART DES OBJETS DU JEU-----*/
randomSeed(analogRead(A6)); //indispensable pour une vraie randomisation
pinMode(8, OUTPUT);
initialise();
pagePresentation();
menuJeu();
}
void loop() {
player.pollSong();
/* CONTROLE DES MOUVEMENTS SUR LES AXES DU JOYSTICK */
if (millis() > (perso.CompteurVitesse + perso.Vitesse))
{
deplacementJoystick();
}
/*CONTROLE DU TIMING DU DEPLACEMENT DU MECHANT */
for (int i = 0; i < niveau.nombreMechants ; i++)
{
if (millis() > (mechant[i].CompteurVitesse + mechant[i].Vitesse))
{ switch (niveau.numero) {
case 1:
case 2:
case 3:
mechantDeplacement(i);
break;
case 4: //BOSS de fin
mechantAttaque(i);
break;
}
}
}
/* CONTROLE DES ACTIONS SUR LE SWITCH DU JOYSTICK */
BP1 = digitalRead(2);
if ((BP1 == LOW) and !munition.estTire and perso.munition > 0)
{
declenchementTir();
}
/* CONTROLE DU DEPLACEMENT DU TIR SI LE TIR A ETE DECLENCHE */
if ((millis() > munition.compteurVitesse + munition.vitesse) and munition.estTire)
{
TirEncours();
}
/*CONTROLE DES EVENTUELLES COLLISIONS ENTRE LES OBJETS DU JEU*/
collisions();
/*AFFICHAGE DES OBJETS ENCORE VIVANTS SUR L'ECRAN LCD*/
actualisationObjetsVivants();
affichageScores();
}