Nettoyage carrosse & addaptation pour buffer

This commit is contained in:
adri 2018-01-09 21:04:00 +01:00
parent 3d7dd90182
commit e2036ae945
2 changed files with 35 additions and 58 deletions

View File

@ -33,8 +33,6 @@ namespace Bonhomme02
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.timerImage = new System.Windows.Forms.Timer(this.components); 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.btnCreationCarrosse = new System.Windows.Forms.Button();
this.NyanCatGif = new System.Windows.Forms.PictureBox(); this.NyanCatGif = new System.Windows.Forms.PictureBox();
this.Obstacle = new System.Windows.Forms.PictureBox(); this.Obstacle = new System.Windows.Forms.PictureBox();
@ -51,41 +49,20 @@ namespace Bonhomme02
this.timerImage.Interval = 500; this.timerImage.Interval = 500;
this.timerImage.Tick += new System.EventHandler(this.timerImage_Tick); 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 // btnCreationCarrosse
// //
this.btnCreationCarrosse.Location = new System.Drawing.Point(13, 468); this.btnCreationCarrosse.Location = new System.Drawing.Point(13, 468);
this.btnCreationCarrosse.Name = "btnCreationCarrosse"; 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.TabIndex = 11;
this.btnCreationCarrosse.Text = "Creer Carrosse"; this.btnCreationCarrosse.Text = "Creer Bonhomme et le faire sauter ";
this.btnCreationCarrosse.UseVisualStyleBackColor = true; this.btnCreationCarrosse.UseVisualStyleBackColor = true;
this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click); this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click);
// //
// NyanCatGif // NyanCatGif
// //
this.NyanCatGif.BackColor = System.Drawing.Color.Gray; 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.Name = "NyanCatGif";
this.NyanCatGif.Size = new System.Drawing.Size(154, 105); this.NyanCatGif.Size = new System.Drawing.Size(154, 105);
this.NyanCatGif.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.NyanCatGif.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
@ -95,7 +72,7 @@ namespace Bonhomme02
// Obstacle // Obstacle
// //
this.Obstacle.BackColor = System.Drawing.Color.Silver; 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.Name = "Obstacle";
this.Obstacle.Size = new System.Drawing.Size(10, 192); this.Obstacle.Size = new System.Drawing.Size(10, 192);
this.Obstacle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.Obstacle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
@ -108,7 +85,7 @@ namespace Bonhomme02
this.Sol.InitialImage = global::Bonhomme02.Properties.Resources.moon; this.Sol.InitialImage = global::Bonhomme02.Properties.Resources.moon;
this.Sol.Location = new System.Drawing.Point(12, 415); this.Sol.Location = new System.Drawing.Point(12, 415);
this.Sol.Name = "Sol"; 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.TabIndex = 12;
this.Sol.TabStop = false; this.Sol.TabStop = false;
// //
@ -117,7 +94,7 @@ namespace Bonhomme02
this.TV.BackColor = System.Drawing.Color.Gray; this.TV.BackColor = System.Drawing.Color.Gray;
this.TV.Location = new System.Drawing.Point(12, 13); this.TV.Location = new System.Drawing.Point(12, 13);
this.TV.Name = "TV"; 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.TabIndex = 0;
this.TV.TabStop = false; this.TV.TabStop = false;
// //
@ -125,13 +102,11 @@ namespace Bonhomme02
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.NyanCatGif);
this.Controls.Add(this.Obstacle); this.Controls.Add(this.Obstacle);
this.Controls.Add(this.Sol); this.Controls.Add(this.Sol);
this.Controls.Add(this.btnCreationCarrosse); this.Controls.Add(this.btnCreationCarrosse);
this.Controls.Add(this.btnEffacer);
this.Controls.Add(this.btnStopDeplacerCTick);
this.Controls.Add(this.TV); this.Controls.Add(this.TV);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.Name = "Form1"; this.Name = "Form1";
@ -151,8 +126,6 @@ namespace Bonhomme02
private System.Windows.Forms.PictureBox TV; private System.Windows.Forms.PictureBox TV;
private System.Windows.Forms.Timer timerImage; 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.Button btnCreationCarrosse;
private System.Windows.Forms.PictureBox Sol; private System.Windows.Forms.PictureBox Sol;
private System.Windows.Forms.PictureBox Obstacle; private System.Windows.Forms.PictureBox Obstacle;

View File

@ -36,7 +36,7 @@ namespace Bonhomme02
if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2) if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2)
{ {
this.timerImage.Stop(); this.timerImage.Stop();
this.btnStopDeplacerCTick.Enabled = false;
} }
else else
{ {
@ -50,7 +50,7 @@ namespace Bonhomme02
private void btnStopDeplacerCTick_Click(object sender, EventArgs e) private void btnStopDeplacerCTick_Click(object sender, EventArgs e)
{ {
this.timerImage.Stop(); this.timerImage.Stop();
this.btnStopDeplacerCTick.Enabled = false;
} }
private void btnEffacer_Click(object sender, EventArgs e) private void btnEffacer_Click(object sender, EventArgs e)
@ -62,6 +62,9 @@ namespace Bonhomme02
private void btnCreationCarrosse_Click(object sender, EventArgs e) private void btnCreationCarrosse_Click(object sender, EventArgs e)
{ {
if (tasks.Count == 0)
{
bonhomme = new Bonhomme(ref this.TV, 80, 80, 50, 20, Math.PI / 2); 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.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.jambe2.Bas.Fond = bonhomme.jambe2.Millieux.Fond = bonhomme.jambe2.Haut.Fond = Color.DeepPink;
@ -69,14 +72,11 @@ namespace Bonhomme02
bonhomme.Afficher(g); bonhomme.Afficher(g);
marche = new Marcher(ref bonhomme, bufferG, this.Sol.Location.Y - this.TV.Location.Y); marche = new Marcher(ref bonhomme, bufferG, this.Sol.Location.Y - this.TV.Location.Y);
Thread.Sleep(1000); Thread.Sleep(1000);
if (tasks.Count == 0)
{
str = global::Bonhomme02.Properties.Resources.NyanCatoriginal; str = global::Bonhomme02.Properties.Resources.NyanCatoriginal;
player.Stream = str; player.Stream = str;
this.NyanCatGif.Image = global::Bonhomme02.Properties.Resources.tumblr_opsismTLqh1vghf22o1_400; this.NyanCatGif.Image = global::Bonhomme02.Properties.Resources.tumblr_opsismTLqh1vghf22o1_400;
player.Play(); 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); marche.Saut(ref this.Obstacle, 5);
})); }));
@ -93,6 +93,10 @@ namespace Bonhomme02
} }
}); });
} }
// https://msdn.microsoft.com/fr-be/Library/dd270696(v=vs.110).aspx
}
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {