diff --git a/Bonhomme02/Form1.Designer.cs b/Bonhomme02/Form1.Designer.cs index 1e4fd1e..ee16e72 100644 --- a/Bonhomme02/Form1.Designer.cs +++ b/Bonhomme02/Form1.Designer.cs @@ -84,7 +84,7 @@ namespace Bonhomme02 // // NyanCatGif // - this.NyanCatGif.BackColor = System.Drawing.Color.Black; + this.NyanCatGif.BackColor = System.Drawing.Color.Gray; this.NyanCatGif.Location = new System.Drawing.Point(995, 13); this.NyanCatGif.Name = "NyanCatGif"; this.NyanCatGif.Size = new System.Drawing.Size(154, 105); @@ -114,7 +114,7 @@ namespace Bonhomme02 // // TV // - this.TV.BackColor = System.Drawing.Color.Black; + this.TV.BackColor = System.Drawing.Color.Gray; this.TV.Location = new System.Drawing.Point(12, 13); this.TV.Name = "TV"; this.TV.Size = new System.Drawing.Size(1137, 449); diff --git a/Bonhomme02/Form1.cs b/Bonhomme02/Form1.cs index 4a967c1..f3aafba 100644 --- a/Bonhomme02/Form1.cs +++ b/Bonhomme02/Form1.cs @@ -78,7 +78,7 @@ namespace Bonhomme02 } // https://msdn.microsoft.com/fr-be/Library/dd270696(v=vs.110).aspx tasks.Add(Task.Factory.StartNew(() => { - marche.Saut(ref this.Obstacle, 1); + marche.Saut(ref this.Obstacle, 5); })); var continuation = Task.WhenAll(tasks); //https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/chaining-tasks-by-using-continuation-tasks Task continuationTask = continuation.ContinueWith((antecedent) => { diff --git a/Bonhomme02/Marcher.cs b/Bonhomme02/Marcher.cs index a3de880..12fe08a 100644 --- a/Bonhomme02/Marcher.cs +++ b/Bonhomme02/Marcher.cs @@ -14,6 +14,7 @@ namespace Bonhomme02 Bonhomme bonhomme; IntPtr? handle; Graphics gr; + Graphics grBuf; BufferedGraphics buff; int ySol; int resolution; @@ -43,7 +44,7 @@ namespace Bonhomme02 Graphics gr = Graphics.FromHwnd(handle); if(handle == null){ bonhomme.Cacher(gr); - buff.Render(); + Rend(); } else bonhomme.Cacher(handle); @@ -53,7 +54,7 @@ namespace Bonhomme02 bonhomme.Coordonnee = newCoo; if(handle == null){ bonhomme.Afficher(gr); - buff.Render(); + Rend(); } else bonhomme.Afficher(handle); @@ -63,6 +64,7 @@ namespace Bonhomme02 { handle = null; step = 0; + grBuf = Graphics.FromHwnd(bonhomme.conteneur.Handle); this.gr = buff.Graphics; this.buff = buff; this.bonhomme = bonhomme; @@ -79,13 +81,13 @@ namespace Bonhomme02 if(bonhomme.jambe1.Bas.CSG.Y != ySol) // On positionne le bonhomme sur le sol { bonhomme.Cacher(gr); - buff.Render(); + Rend(); Point newCoo; int longeurTTBonhome = bonhomme.jambe1.Bas.CSG.Y - bonhomme.CIG.Y ;// de pied.csg à bonhome.cig newCoo = new Point(bonhomme.CIG.X, ySol - longeurTTBonhome); bonhomme.Coordonnee = newCoo; bonhomme.Afficher(gr); - buff.Render(); + Rend(); } } public void Avancer() @@ -115,7 +117,7 @@ namespace Bonhomme02 bonhomme.Afficher(handle.Value); dejaDeplacer += resolution; if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } @@ -139,7 +141,7 @@ namespace Bonhomme02 bonhomme.Afficher(handle.Value); dejaDeplacer += resolution; if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } CollerAuSol(ref bonhomme.jambe2); //Voir issues #24 @@ -149,20 +151,20 @@ namespace Bonhomme02 { if(handle == null){ bonhomme.Cacher(gr); - + } else bonhomme.Cacher(handle.Value); bonhomme.jambe1.BougerBas(0, resolution); if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); dejaDeplacer += resolution; if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); if (neww != bonhomme.jambe1.Bas.CSG.Y) { @@ -182,7 +184,7 @@ namespace Bonhomme02 { if(handle == null){ bonhomme.Cacher(gr); - + } else bonhomme.Cacher(handle.Value); @@ -205,13 +207,13 @@ namespace Bonhomme02 bonhomme.Coordonnee = new Point(bonhomme.Coordonnee.X + resolution, bonhomme.Coordonnee.Y); if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); dejaDeplacer += resolution; if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } break; @@ -220,38 +222,38 @@ namespace Bonhomme02 { if(handle == null){ bonhomme.Cacher(gr); - + } else bonhomme.Cacher(handle.Value); bonhomme.jambe2.BougerBas(0, resolution); if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); dejaDeplacer += resolution; if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } if(handle == null){ bonhomme.Cacher(gr); - + } else bonhomme.Cacher(handle.Value); bonhomme.InterevrtirJambe();// On inverse les deux jambe, jambe1=jambe2 et jambe2=jambe1 if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); if (handle == null) - buff.Render(); + Rend(); step +=3; // retour step 3 break; } @@ -279,7 +281,7 @@ namespace Bonhomme02 //Graphics gr = Graphics.FromHwnd(handle.Value); if(handle == null){ bonhomme.Cacher(gr); - + } else bonhomme.Cacher(handle.Value); @@ -289,13 +291,13 @@ namespace Bonhomme02 bonhomme.Coordonnee = newCoo; if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); if (handle == null) - buff.Render(); + Rend(); } } public void Saut(ref PictureBox osbtacle, int vitesse) @@ -322,12 +324,12 @@ namespace Bonhomme02 } if(handle == null){ bonhomme.Afficher(gr); - + } else bonhomme.Afficher(handle.Value); if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } while (bonhomme.jambe1.Bas.CSG.Y < ySol)//descendre @@ -355,11 +357,21 @@ namespace Bonhomme02 bonhomme.Afficher(handle.Value); if (handle == null) - buff.Render(); + Rend(); Thread.Sleep(vitesse); } Avancer(vitesse, bonhomme.conteneur.Location.X + bonhomme.conteneur.Width, 3); } + public void Rend() + { + if (handle == null) + { + gr.FillRectangle(new SolidBrush(bonhomme.conteneur.BackColor), 0, 0, bonhomme.conteneur.Width, bonhomme.conteneur.Height); + bonhomme.Afficher(gr); + buff.Render(); + } + + } } } diff --git a/Bonhomme02/Resources/Super Mario Bros Win Stage Sound Effect.wav b/Bonhomme02/Resources/Super Mario Bros Win Stage Sound Effect.wav new file mode 100644 index 0000000..d2af339 Binary files /dev/null and b/Bonhomme02/Resources/Super Mario Bros Win Stage Sound Effect.wav differ