Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 11:0b85a680ad28, committed 2022-03-28
- Comitter:
- guibouu
- Date:
- Mon Mar 28 17:50:41 2022 +0000
- Parent:
- 10:6f9340af7926
- Commit message:
- projet2
Changed in this revision
--- a/LED2.h Tue Sep 14 13:45:11 2021 +0000
+++ b/LED2.h Mon Mar 28 17:50:41 2022 +0000
@@ -1,4 +1,9 @@
// Rassurez vous, VOUS n'avez pas a changer ces lignes de commandes
+extern int mvie;
+extern int mvie2;
+extern int autoritir1;
+extern int autoritir2;
+
// variables propres Affichage vers led en 16 bandes
int AL ; int AP ; int AT ; // Affichae AL ligne AP pix AT temps
@@ -168,4 +173,59 @@
pix ( px , py , br , bv , bb );
}
-
\ No newline at end of file
+
+ void carre( int xd, int yd , int longueur , int hauteur , int vr , int vv , int vb )
+ {
+ int jesus;
+ int oui;
+ for(jesus=0;jesus<hauteur;jesus=jesus+1)
+ {
+ for(oui=0;oui<longueur;oui=oui+1)
+ {
+ pix(xd+oui,yd+jesus,vr,vv,vb);
+ }
+ }
+}
+
+void mob(int x,int y,int vie) // a éteindre
+ {
+ if(vie>=1)
+ {
+ pix(x,y,0,0,4);
+ pix(x,y+1,0,0,4);
+ pix(x-1,y+1,0,0,4);
+ pix(x+1,y+1,0,0,4);
+ pix(x+1,y+2,0,0,4);
+ pix(x-1,y+2,0,0,4);
+ }
+
+}
+/*hitmob(20,20,mvie,15+vaisseauy+ccyy+tir2/4,vaisseauy+ccyy+tir/4,tirx2,tirx,autoritir2,autoritir1) */
+
+void hitmob(int x,int y,int vie,int ty2,int ty1,int tx2,int tx1,int auto2,int auto1)
+{ if(tx2<x+2 && tx2>x-2 && ty2>=y-1 && ty2>=y-1 && auto2==1 && vie>0)
+ {
+ mvie=mvie-1;
+ autoritir2=0;
+ }
+ if(tx1<x+2 && tx1>x-2 && ty1>=y-1 && ty1>=y-1 && auto1==1 && vie>0)
+ {
+ mvie=mvie-1;
+ autoritir1=0;
+ }
+ }
+
+ void hitmob2(int x,int y,int vie,int ty2,int ty1,int tx2,int tx1,int auto2,int auto1)
+{ if(tx2<x+2 && tx2>x-2 && ty2>=y-1 && ty2>=y-1 && auto2==1 && vie>0)
+ {
+ mvie2=mvie2-1;
+ autoritir2=0;
+ }
+ if(tx1<x+2 && tx1>x-2 && ty1>=y-1 && ty1>=y-1 && auto1==1 && vie>0)
+ {
+ mvie2=mvie2-1;
+ autoritir1=0;
+ }
+ }
+
+
--- a/draw.h Tue Sep 14 13:45:11 2021 +0000
+++ b/draw.h Mon Mar 28 17:50:41 2022 +0000
@@ -1,20 +1,294 @@
-// lieu de vos variables avec 'a' au début
-int atiti = 5; // exemple
-// vos fonctions commenceront TOUJOURS par "a" comme atiti !!
-void atest(void)
- {
- atiti = 15 ; // exemple pour le plaisir mais non appelée
- }
+int ext;
+int temps=0;
+int effet[2]={14,14};
+int effet1[2]={14,14};
+int effet2[2]={14,14};
+int effet3[2]={14,14};
+int effet4[2]={14,14};
+//tir
+int tir=0;
+int tir2=0;
+int tirx;
+int tirx2;
+
+int autoritir1=1;
+int autoritir2=1;
+
+//menu variable
+int menubleu=0;
+int menub=0;
+int menurouge=0;
+int menur=0;
+int zeno=1;
+
+//mob
+int mvie =100;
+int xmob1 =20;
+int ymob1=20;
+int xdepm=0;
+int ydepm=0;
+//mob 2
+int mvie2=100;
+int xmob2=13;
+int ymob2=25;
+int xdepm2=6;
+int ydepm2=0;
+//deplacement mob
+
+ int timedep=0;
+ int timetab=0;
+ int tabdep[18]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
+
+
+
+//menu
void draw() // ici vous exprimez vos dessins (jamais de delai dans cette boucle)
- { // DEBUT de vos dessins
- pix( 15 , atiti , 0 , 5 , 0 ); // pixel vert x = 15 , y = atiti
- pix( posx , atiti + 1 , 0 , 0 , 5 ); // pixel bleu x = posx , = atiti+1
- // posx change en fonction de la reception serie ( allez dans serie.h)
- pix ( ccx+15 , ccy+15 ,7,7,0); // ccx et ccy issu de l'accéléro
- clown(); // joli dessin
- serie.printf("Bonjour :) \r\n") ; // envoyer un texte en liaison serie
- } // FIN de vos dessins
+ { // DEBUT de vos dessins
+ if(zeno==1)
+{
+ if(ccy*1.4>=3 && ccx<4 && ccx>-4 && ccy*1.4<11)
+ {
+ menubleu=menubleu+1;
+ if(menubleu>=20)
+ {
+ menubleu=menubleu-20;
+ menub=menub+1;
+ }
+
+ }
+ //bleu moins
+ if(ccy<=0)
+ {
+ menubleu=menubleu+1;
+ if(menubleu>=10&&menub>0)
+ {
+ menubleu=menubleu-10;
+ menub=menub+-1;
+ }
+
+ }
+
+ //rouge plus
+ if(ccy*1.4<=-4 && ccx<4 && ccx>-4 && ccy*1.4>-11)
+ {
+ menurouge=menurouge+1;
+ if(menurouge>=20)
+ {
+ menurouge=menurouge-20;
+ menur=menur+1;
+ }
+
+ }
+ //bleu moins
+ if(ccy>=0)
+ {
+ menurouge=menurouge+1;
+ if(menurouge>=10&&menur>0)
+ {
+ menurouge=menurouge-10;
+ menur=menur+-1;
+ }
+
+ }
+ carre(0,16,menub,16,1,0,0);
+ carre(0,0,menur,16,0,0,1);
+
+
+ carre(13,6,7,7,1,1,1);
+ carre(15,18,3,7,1,1,1);
+ carre(13,20,7,3,1,1,1);
+ carre(14,19,5,5,1,1,1);
+ if(menub>=35)
+{
+ zeno=0;
+}
+pix(16+ccx,15+ccy*1.4,1,1,0);
+
+pix(16+ccx,14+ccy*1.4,0,1,0);
+pix(16+ccx,16+ccy*1.4,0,1,0);
+pix(15+ccx,15+ccy*1.4,0,1,0);
+pix(17+ccx,15+ccy*1.4,0,1,0);
+ }
+
+ //variables
+int ccxx=ccx*1.3;
+int ccyy=ccy*1.3;
+int vaisseaux = 15;
+int vaisseauy =10;//lieu de base du vaisseau
+
+
+
+
+
+
+
+if(zeno==0)
+{
+ //mob
+ mob(xmob1,ymob1,mvie);
+ mob(xmob2,ymob2,mvie2);
+ //dégats mobs
+ hitmob(xmob1,ymob1,mvie,15+vaisseauy+ccyy+tir2/4,vaisseauy+ccyy+tir/4,tirx2,tirx,autoritir2,autoritir1);
+ hitmob2(xmob2,ymob2,mvie2,15+vaisseauy+ccyy+tir2/4,vaisseauy+ccyy+tir/4,tirx2,tirx,autoritir2,autoritir1);
+ //déplacement
+ timedep=timedep+1;
+ timetab=timetab+1;
+ if(timetab>17)
+ {
+ timetab=timetab-17;
+ }
+ //mouvement
+ if(timedep>15)
+ {
+ timedep=timedep-15;
+ //mob1
+ if(xdepm>0)
+ {
+ xmob1=xmob1+1;
+ xdepm=xdepm-1;
+ }
+
+ if(xdepm<0)
+ {
+ xmob1=xmob1-1;
+ xdepm=xdepm+1;
+ }
+ //mob2
+ if(xdepm2>0)
+ {
+ xmob2=xmob2+1;
+ xdepm2=xdepm2-1;
+ }
+
+ if(xdepm2<0)
+ {
+ xmob2=xmob2-1;
+ xdepm2=xdepm2+1;
+ }
+ }
+
+ //deplacement incrementation
+ //mob1
+ if(xdepm==0)
+ {
+ if (xmob1>=15)
+ {
+ xdepm=xdepm-tabdep[timetab];
+ }
+ else
+ {
+ xdepm=xdepm+tabdep[timetab];
+ }
+ }
+ //mob2
+ if(xdepm2==0)
+ {
+ if (xmob2>=15)
+ {
+ xdepm2=xdepm2-tabdep[timetab];
+ }
+ else
+ {
+ xdepm2=xdepm2+tabdep[timetab];
+ }
+ }
+ //effets vaisseau
+ temps=temps+1;
+ if(temps>=30)
+ {
+ temps=temps-30;
+ effet[0]=vaisseaux+ccxx;
+ effet[1]=vaisseauy+ccyy;
+ }
+ if(temps==5)
+ {
+ effet1[0]=vaisseaux+ccxx;
+ effet1[1]=vaisseauy+ccyy;
+ }
+ if(temps==10)
+ {
+ effet2[0]=vaisseaux+ccxx;
+ effet2[1]=vaisseauy+ccyy;
+ }
+ if(temps==15)
+ {
+ effet3[0]=vaisseaux+ccxx;
+ effet3[1]=vaisseauy+ccyy;
+ }
+ if(temps==20)
+ {
+ effet4[0]=vaisseaux+ccxx;
+ effet4[1]=vaisseauy+ccyy;
+ }
+
+
+ pix ( effet[0], effet[1],0,0,1);
+ pix ( effet1[0], effet1[1],0,0,1);
+ pix ( effet2[0], effet2[1],0,0,1);
+ pix ( effet3[0], effet3[1],0,0,1);
+ pix ( effet4[0], effet4[1],0,0,1);
+//tir1
+tir=tir+1;
+ if(tir>=120)
+ {
+ tir=tir-120;
+ tirx=vaisseaux+ccxx;
+ autoritir1=1;
+ }
+ if(vaisseauy+ccyy+tir/4<=32 && autoritir1==1)
+ {
+pix(tirx,vaisseauy+ccyy+tir/4,1,0,1);
+}
+//tir2
+tir2=tir2+1;
+if(tir2>=60)
+ {
+ tir2=tir2-120;
+ tirx2=vaisseaux+ccxx;
+ autoritir2=1;
+ }
+ if(15+vaisseauy+ccyy+tir2/4<=32 && autoritir2==1)
+ {
+pix(tirx2,15+vaisseauy+ccyy+tir2/4,1,0,1);
+}
+
+ //vaisseau
+
+pix ( vaisseaux+ccxx, vaisseauy+ccyy,1,1,1);
+pix ( vaisseaux+ccxx, vaisseauy+1+ccyy,1,1,1);
+pix ( vaisseaux+ccxx, vaisseauy-1+ccyy,1,1,1);
+pix ( vaisseaux+1+ccxx, vaisseauy-1+ccyy,1,1,1);
+pix ( vaisseaux-1+ccxx, vaisseauy-1+ccyy,1,1,1);
+
+}
+/*
+ serie.printf("D%dX \r\n",ccxx+15) ; // envoyer un texte en liaison serie
+ serie.printf("D%dY \r\n",ccyy+15) ;
+ charr(14, 18 , ext);
+ */
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // FIN de vos dessins
// fonctions et variables deja créées
--- a/serie.h Tue Sep 14 13:45:11 2021 +0000
+++ b/serie.h Mon Mar 28 17:50:41 2022 +0000
@@ -5,11 +5,21 @@
{ // ici on decode un exemple simple
// un 'a' met posx = 10 un 'b' met posx = 20
arecv = serie.getc();
- if (arecv == 'a') // c'est un 'a' qui arrive
- { posx = 10 ; // la position x changera
+ if (arecv == 'a')
+ {
+ ext=1;
}
- if (arecv == 'b')// c'est un 'b' qui arrive
- { posx = 20 ;
- }
+ if (arecv == 'b')
+ {
+ ext=2;
+ }
+ if (arecv == 'c')
+ {
+ ext=3;
+ }
+ if (arecv == 'd')
+ {
+ ext=0;
+ }
return;
}
\ No newline at end of file