diff --git a/Bonhomme02/Form1.Designer.cs b/Bonhomme02/Form1.Designer.cs index ee16e72..e746409 100644 --- a/Bonhomme02/Form1.Designer.cs +++ b/Bonhomme02/Form1.Designer.cs @@ -33,8 +33,6 @@ namespace Bonhomme02 { this.components = new System.ComponentModel.Container(); this.timerImage = new System.Windows.Forms.Timer(this.components); - this.btnEffacer = new System.Windows.Forms.Button(); - this.btnStopDeplacerCTick = new System.Windows.Forms.Button(); this.btnCreationCarrosse = new System.Windows.Forms.Button(); this.NyanCatGif = new System.Windows.Forms.PictureBox(); this.Obstacle = new System.Windows.Forms.PictureBox(); @@ -51,41 +49,20 @@ namespace Bonhomme02 this.timerImage.Interval = 500; this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick); // - // btnEffacer - // - this.btnEffacer.Location = new System.Drawing.Point(13, 497); - this.btnEffacer.Name = "btnEffacer"; - this.btnEffacer.Size = new System.Drawing.Size(567, 23); - this.btnEffacer.TabIndex = 10; - this.btnEffacer.Text = "Effacer Tout"; - this.btnEffacer.UseVisualStyleBackColor = true; - this.btnEffacer.Click += new System.EventHandler(this.btnEffacer_Click); - // - // btnStopDeplacerCTick - // - this.btnStopDeplacerCTick.Enabled = false; - this.btnStopDeplacerCTick.Location = new System.Drawing.Point(584, 497); - this.btnStopDeplacerCTick.Name = "btnStopDeplacerCTick"; - this.btnStopDeplacerCTick.Size = new System.Drawing.Size(565, 23); - this.btnStopDeplacerCTick.TabIndex = 9; - this.btnStopDeplacerCTick.Text = "Stop Tick"; - this.btnStopDeplacerCTick.UseVisualStyleBackColor = true; - this.btnStopDeplacerCTick.Click += new System.EventHandler(this.btnStopDeplacerCTick_Click); - // // btnCreationCarrosse // this.btnCreationCarrosse.Location = new System.Drawing.Point(13, 468); this.btnCreationCarrosse.Name = "btnCreationCarrosse"; - this.btnCreationCarrosse.Size = new System.Drawing.Size(1136, 23); + this.btnCreationCarrosse.Size = new System.Drawing.Size(1246, 23); this.btnCreationCarrosse.TabIndex = 11; - this.btnCreationCarrosse.Text = "Creer Carrosse"; + this.btnCreationCarrosse.Text = "Creer Bonhomme et le faire sauter "; this.btnCreationCarrosse.UseVisualStyleBackColor = true; this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click); // // NyanCatGif // this.NyanCatGif.BackColor = System.Drawing.Color.Gray; - this.NyanCatGif.Location = new System.Drawing.Point(995, 13); + this.NyanCatGif.Location = new System.Drawing.Point(1105, 13); this.NyanCatGif.Name = "NyanCatGif"; this.NyanCatGif.Size = new System.Drawing.Size(154, 105); this.NyanCatGif.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -95,7 +72,7 @@ namespace Bonhomme02 // Obstacle // this.Obstacle.BackColor = System.Drawing.Color.Silver; - this.Obstacle.Location = new System.Drawing.Point(750, 224); + this.Obstacle.Location = new System.Drawing.Point(909, 223); this.Obstacle.Name = "Obstacle"; this.Obstacle.Size = new System.Drawing.Size(10, 192); this.Obstacle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; @@ -108,7 +85,7 @@ namespace Bonhomme02 this.Sol.InitialImage = global::Bonhomme02.Properties.Resources.moon; this.Sol.Location = new System.Drawing.Point(12, 415); this.Sol.Name = "Sol"; - this.Sol.Size = new System.Drawing.Size(1137, 47); + this.Sol.Size = new System.Drawing.Size(1247, 47); this.Sol.TabIndex = 12; this.Sol.TabStop = false; // @@ -117,7 +94,7 @@ namespace Bonhomme02 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); + this.TV.Size = new System.Drawing.Size(1247, 449); this.TV.TabIndex = 0; this.TV.TabStop = false; // @@ -125,13 +102,11 @@ namespace Bonhomme02 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1161, 538); + this.ClientSize = new System.Drawing.Size(1271, 502); this.Controls.Add(this.NyanCatGif); this.Controls.Add(this.Obstacle); this.Controls.Add(this.Sol); this.Controls.Add(this.btnCreationCarrosse); - this.Controls.Add(this.btnEffacer); - this.Controls.Add(this.btnStopDeplacerCTick); this.Controls.Add(this.TV); this.DoubleBuffered = true; this.Name = "Form1"; @@ -151,8 +126,6 @@ namespace Bonhomme02 private System.Windows.Forms.PictureBox TV; private System.Windows.Forms.Timer timerImage; - private System.Windows.Forms.Button btnEffacer; - private System.Windows.Forms.Button btnStopDeplacerCTick; private System.Windows.Forms.Button btnCreationCarrosse; private System.Windows.Forms.PictureBox Sol; private System.Windows.Forms.PictureBox Obstacle; diff --git a/Bonhomme02/Form1.cs b/Bonhomme02/Form1.cs index f3aafba..867f699 100644 --- a/Bonhomme02/Form1.cs +++ b/Bonhomme02/Form1.cs @@ -36,7 +36,7 @@ namespace Bonhomme02 if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2) { this.timerImage.Stop(); - this.btnStopDeplacerCTick.Enabled = false; + } else { @@ -50,7 +50,7 @@ namespace Bonhomme02 private void btnStopDeplacerCTick_Click(object sender, EventArgs e) { this.timerImage.Stop(); - this.btnStopDeplacerCTick.Enabled = false; + } private void btnEffacer_Click(object sender, EventArgs e) @@ -62,36 +62,40 @@ namespace Bonhomme02 private void btnCreationCarrosse_Click(object sender, EventArgs e) { - bonhomme = new Bonhomme(ref this.TV, 80, 80, 50, 20, Math.PI / 2); - bonhomme.jambe1.Bas.Fond = bonhomme.jambe1.Millieux.Fond = bonhomme.jambe1.Haut.Fond = Color.Pink; - bonhomme.jambe2.Bas.Fond = bonhomme.jambe2.Millieux.Fond = bonhomme.jambe2.Haut.Fond = Color.DeepPink; - bonhomme.tete.Fond = Color.Pink; - bonhomme.Afficher(g); - marche = new Marcher(ref bonhomme, bufferG, this.Sol.Location.Y-this.TV.Location.Y); - Thread.Sleep(1000); + if (tasks.Count == 0) { + bonhomme = new Bonhomme(ref this.TV, 80, 80, 50, 20, Math.PI / 2); + bonhomme.jambe1.Bas.Fond = bonhomme.jambe1.Millieux.Fond = bonhomme.jambe1.Haut.Fond = Color.Pink; + bonhomme.jambe2.Bas.Fond = bonhomme.jambe2.Millieux.Fond = bonhomme.jambe2.Haut.Fond = Color.DeepPink; + bonhomme.tete.Fond = Color.Pink; + bonhomme.Afficher(g); + marche = new Marcher(ref bonhomme, bufferG, this.Sol.Location.Y - this.TV.Location.Y); + Thread.Sleep(1000); + str = global::Bonhomme02.Properties.Resources.NyanCatoriginal; player.Stream = str; this.NyanCatGif.Image = global::Bonhomme02.Properties.Resources.tumblr_opsismTLqh1vghf22o1_400; player.Play(); - } - // https://msdn.microsoft.com/fr-be/Library/dd270696(v=vs.110).aspx - tasks.Add(Task.Factory.StartNew(() => { + tasks.Add(Task.Factory.StartNew(() => { 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) => { - tasks.RemoveAt(0); - if (tasks.Count == 0) - { - player.Stop(); - str = str = global::Bonhomme02.Properties.Resources.Super_Mario_Bros_Win_Stage_Sound_Effect; - player.Stream = str; - player.Play(); - this.NyanCatGif.Image = null; - } - }); + 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) => { + tasks.RemoveAt(0); + if (tasks.Count == 0) + { + player.Stop(); + str = str = global::Bonhomme02.Properties.Resources.Super_Mario_Bros_Win_Stage_Sound_Effect; + player.Stream = str; + player.Play(); + this.NyanCatGif.Image = null; + } + }); + } + // https://msdn.microsoft.com/fr-be/Library/dd270696(v=vs.110).aspx + + } private void Form1_Load(object sender, EventArgs e)