Ajout BufferG #bourrin, Bug Fond Noir
This commit is contained in:
parent
20543021ef
commit
4aaaeeefb7
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Base des objets Bras et jambe
|
||||
* Base des objets Bras et jambe
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
@ -34,9 +34,9 @@ namespace Bonhomme02
|
|||
this.longueur = longueur;
|
||||
this.Haut = this;
|
||||
this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur / 2, epaisseur, angle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public new void Afficher(IntPtr handle)
|
||||
{
|
||||
if(base.Visible)
|
||||
|
@ -45,7 +45,7 @@ namespace Bonhomme02
|
|||
Millieux.Afficher(handle);
|
||||
Bas.Afficher(handle);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public new void Cacher(IntPtr handle)
|
||||
{
|
||||
|
@ -53,6 +53,22 @@ namespace Bonhomme02
|
|||
Millieux.Cacher(handle);
|
||||
Bas.Cacher(handle);
|
||||
}
|
||||
public new void Afficher(Graphics gr)
|
||||
{
|
||||
if(base.Visible)
|
||||
{
|
||||
Haut.Afficher(gr);
|
||||
Millieux.Afficher(gr);
|
||||
Bas.Afficher(gr);
|
||||
}
|
||||
|
||||
}
|
||||
public new void Cacher(Graphics gr)
|
||||
{
|
||||
Haut.Cacher(gr);
|
||||
Millieux.Cacher(gr);
|
||||
Bas.Cacher(gr);
|
||||
}
|
||||
public double TrouverAngleHaut(Point pt)
|
||||
{
|
||||
Point ptOrigine = parent.Coordonnee + parent.longueur;
|
||||
|
@ -109,7 +125,7 @@ namespace Bonhomme02
|
|||
{
|
||||
Haut.Angle = TrouverAngleHaut(nouveauPtMillieux);
|
||||
Millieux.Angle = TrouverAngleMillieux(nouveauPtBas);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void BougerXHaut(int x, ref Bonhomme bonhomme)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Bonhomme02
|
|||
|
||||
private bool _Visible = true;
|
||||
private PictureBox _Hebergeur;
|
||||
public Color backGround = Color.Gray;
|
||||
private Color _Fond = Color.Blue;
|
||||
private Color _Crayon = Color.Black;
|
||||
private Boolean remplir = true;
|
||||
|
|
|
@ -13,32 +13,36 @@ namespace Bonhomme02
|
|||
public Tete tete;
|
||||
public Jambe jambe1, jambe2;
|
||||
public Bras bras;
|
||||
public PictureBox conteneur;
|
||||
|
||||
public Bonhomme() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Bonhomme(PictureBox hebergeur) : base( hebergeur)
|
||||
public Bonhomme(ref PictureBox hebergeur) : base( hebergeur)
|
||||
{
|
||||
this.conteneur = hebergeur;
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, double lg, double ep, double angle) : base( hebergeur, lg, ep, angle)
|
||||
public Bonhomme(ref PictureBox hebergeur, double lg, double ep, double angle) : base( hebergeur, lg, ep, angle)
|
||||
{
|
||||
|
||||
this.conteneur = hebergeur;
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, int xy) : base( hebergeur, xy)
|
||||
public Bonhomme(ref PictureBox hebergeur, int xy) : base( hebergeur, xy)
|
||||
{
|
||||
this.conteneur = hebergeur;
|
||||
}
|
||||
|
||||
public Bonhomme(PictureBox hebergeur, int x, int y, double lg, double ep, double angle) : base( hebergeur, x, y, lg, ep, angle)
|
||||
public Bonhomme(ref PictureBox hebergeur, int x, int y, double lg, double ep, double angle) : base( hebergeur, x, y, lg, ep, angle)
|
||||
{
|
||||
this.conteneur = hebergeur;
|
||||
Peau me = this;
|
||||
jambe1 = new Jambe(hebergeur, ref me, lg, ep/4, Math.PI / 2);
jambe2 = new Jambe(hebergeur, ref me, lg, ep / 4, Math.PI / 2);
tete = new Tete(hebergeur, ref me, (int)(ep*3.5/4));
|
||||
bras = new Bras(hebergeur, ref me, lg, ep/4, Math.PI / 2);
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, ref Peau parent, double lg, double ep, double angle) : base( hebergeur, ref parent, lg, ep, angle)
|
||||
public Bonhomme(ref PictureBox hebergeur, ref Peau parent, double lg, double ep, double angle) : base( hebergeur, ref parent, lg, ep, angle)
|
||||
{
|
||||
|
||||
this.conteneur = hebergeur;
|
||||
}
|
||||
public new void Afficher(IntPtr handle)
|
||||
{
|
||||
|
@ -48,14 +52,29 @@ namespace Bonhomme02
|
|||
jambe2.Afficher(handle);
|
||||
bras.Afficher(handle);
|
||||
}
|
||||
|
||||
public new void Cacher(IntPtr handle)
|
||||
public new void Afficher(Graphics gr)
|
||||
{
|
||||
base.Cacher(handle);
|
||||
tete.Cacher(handle);
|
||||
jambe1.Cacher(handle);
|
||||
jambe2.Cacher(handle);
|
||||
bras.Cacher(handle);
|
||||
base.Afficher(gr);
|
||||
tete.Afficher(gr);
|
||||
jambe1.Afficher(gr);
|
||||
jambe2.Afficher(gr);
|
||||
bras.Afficher(gr);
|
||||
}
|
||||
public void Afficher()
|
||||
{
|
||||
Afficher(conteneur.Handle);
|
||||
}
|
||||
public new void Cacher(Graphics gr)
|
||||
{
|
||||
base.Cacher(gr);
|
||||
tete.Cacher(gr);
|
||||
jambe1.Cacher(gr);
|
||||
jambe2.Cacher(gr);
|
||||
bras.Cacher(gr);
|
||||
}
|
||||
public void Cacher()
|
||||
{
|
||||
Cacher(conteneur.Handle);
|
||||
}
|
||||
public void InterevrtirJambe()
|
||||
{
|
||||
|
|
|
@ -102,5 +102,8 @@
|
|||
<ItemGroup>
|
||||
<None Include="Resources\NyanCatoriginal.wav" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\Super Mario Bros Win Stage Sound Effect.wav" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -36,12 +36,12 @@ namespace Bonhomme02
|
|||
this.btnEffacer = new System.Windows.Forms.Button();
|
||||
this.btnStopDeplacerCTick = new System.Windows.Forms.Button();
|
||||
this.btnCreationCarrosse = new System.Windows.Forms.Button();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.NyanCatGif = new System.Windows.Forms.PictureBox();
|
||||
this.Obstacle = new System.Windows.Forms.PictureBox();
|
||||
this.Sol = new System.Windows.Forms.PictureBox();
|
||||
this.TV = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NyanCatGif)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Obstacle)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Sol)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TV)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
|
@ -82,25 +82,25 @@ namespace Bonhomme02
|
|||
this.btnCreationCarrosse.UseVisualStyleBackColor = true;
|
||||
this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click);
|
||||
//
|
||||
// pictureBox2
|
||||
// NyanCatGif
|
||||
//
|
||||
this.pictureBox2.BackColor = System.Drawing.Color.Gray;
|
||||
this.pictureBox2.Location = new System.Drawing.Point(995, 13);
|
||||
this.pictureBox2.Name = "pictureBox2";
|
||||
this.pictureBox2.Size = new System.Drawing.Size(154, 105);
|
||||
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox2.TabIndex = 14;
|
||||
this.pictureBox2.TabStop = false;
|
||||
this.NyanCatGif.BackColor = System.Drawing.Color.Black;
|
||||
this.NyanCatGif.Location = new System.Drawing.Point(995, 13);
|
||||
this.NyanCatGif.Name = "NyanCatGif";
|
||||
this.NyanCatGif.Size = new System.Drawing.Size(154, 105);
|
||||
this.NyanCatGif.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.NyanCatGif.TabIndex = 14;
|
||||
this.NyanCatGif.TabStop = false;
|
||||
//
|
||||
// pictureBox1
|
||||
// Obstacle
|
||||
//
|
||||
this.pictureBox1.BackColor = System.Drawing.Color.Silver;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(750, 224);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(10, 192);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox1.TabIndex = 13;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.Obstacle.BackColor = System.Drawing.Color.Silver;
|
||||
this.Obstacle.Location = new System.Drawing.Point(750, 224);
|
||||
this.Obstacle.Name = "Obstacle";
|
||||
this.Obstacle.Size = new System.Drawing.Size(10, 192);
|
||||
this.Obstacle.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.Obstacle.TabIndex = 13;
|
||||
this.Obstacle.TabStop = false;
|
||||
//
|
||||
// Sol
|
||||
//
|
||||
|
@ -114,7 +114,7 @@ namespace Bonhomme02
|
|||
//
|
||||
// TV
|
||||
//
|
||||
this.TV.BackColor = System.Drawing.Color.Gray;
|
||||
this.TV.BackColor = System.Drawing.Color.Black;
|
||||
this.TV.Location = new System.Drawing.Point(12, 13);
|
||||
this.TV.Name = "TV";
|
||||
this.TV.Size = new System.Drawing.Size(1137, 449);
|
||||
|
@ -126,19 +126,20 @@ 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.Controls.Add(this.pictureBox2);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
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";
|
||||
this.Text = "Dessins Animés";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NyanCatGif)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Obstacle)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.Sol)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TV)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -154,8 +155,8 @@ namespace Bonhomme02
|
|||
private System.Windows.Forms.Button btnStopDeplacerCTick;
|
||||
private System.Windows.Forms.Button btnCreationCarrosse;
|
||||
private System.Windows.Forms.PictureBox Sol;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.PictureBox pictureBox2;
|
||||
private System.Windows.Forms.PictureBox Obstacle;
|
||||
private System.Windows.Forms.PictureBox NyanCatGif;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Bonhomme02
|
|||
private BufferedGraphics bufferG = null;
|
||||
private Graphics g;
|
||||
SoundPlayer player = new SoundPlayer();
|
||||
Stream str = global::Bonhomme02.Properties.Resources.NyanCatoriginal;
|
||||
Stream str;
|
||||
List<Task> tasks = new List<Task>();
|
||||
public Form1()
|
||||
{
|
||||
|
@ -40,10 +40,10 @@ namespace Bonhomme02
|
|||
}
|
||||
else
|
||||
{
|
||||
bonhomme.Cacher(this.TV.Handle);
|
||||
bonhomme.Cacher(g);
|
||||
bonhomme.coordonnee = new Point(bonhomme.coordonnee.X + 3, bonhomme.coordonnee.Y + 0);
|
||||
bonhomme.jambe1.BougerBas(+3, -3);
|
||||
bonhomme.Afficher(this.TV.Handle);
|
||||
bonhomme.Afficher(g);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,22 +62,23 @@ namespace Bonhomme02
|
|||
private void btnCreationCarrosse_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bonhomme = new Bonhomme(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.jambe2.Bas.Fond = bonhomme.jambe2.Millieux.Fond = bonhomme.jambe2.Haut.Fond = Color.DeepPink;
|
||||
bonhomme.tete.Fond = Color.Pink;
|
||||
bonhomme.Afficher(this.TV.Handle);
|
||||
marche = new Marcher(ref bonhomme, this.TV.Handle, this.Sol.Location.Y-this.TV.Location.Y);
|
||||
bonhomme.Afficher(g);
|
||||
marche = new Marcher(ref bonhomme, bufferG, this.Sol.Location.Y-this.TV.Location.Y);
|
||||
Thread.Sleep(1000);
|
||||
if (tasks.Count == 0)
|
||||
{
|
||||
str = global::Bonhomme02.Properties.Resources.NyanCatoriginal;
|
||||
player.Stream = str;
|
||||
this.pictureBox2.Image = global::Bonhomme02.Properties.Resources.tumblr_opsismTLqh1vghf22o1_400;
|
||||
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(() => {
|
||||
marche.Avancer(1, this.TV.Width);
|
||||
marche.Saut(ref this.Obstacle, 1);
|
||||
}));
|
||||
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) => {
|
||||
|
@ -85,7 +86,10 @@ namespace Bonhomme02
|
|||
if (tasks.Count == 0)
|
||||
{
|
||||
player.Stop();
|
||||
this.pictureBox2.Image = null;
|
||||
str = str = global::Bonhomme02.Properties.Resources.Super_Mario_Bros_Win_Stage_Sound_Effect;
|
||||
player.Stream = str;
|
||||
player.Play();
|
||||
this.NyanCatGif.Image = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,17 +5,21 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Bonhomme02
|
||||
{
|
||||
class Marcher
|
||||
{
|
||||
Bonhomme bonhomme;
|
||||
IntPtr handle;
|
||||
IntPtr? handle;
|
||||
Graphics gr;
|
||||
BufferedGraphics buff;
|
||||
int ySol;
|
||||
int resolution;
|
||||
int deltaXYmax = 10;
|
||||
int step, cooXMax = 0;
|
||||
int vitesse;
|
||||
public Marcher()
|
||||
{
|
||||
|
||||
|
@ -28,7 +32,7 @@ namespace Bonhomme02
|
|||
this.ySol = ySol;
|
||||
resolution = 1;
|
||||
deltaXYmax = (int)Math.Round(3*bonhomme.jambe1.longueur.ABS/4);
|
||||
|
||||
|
||||
//Reset de tous les angle au cas ou
|
||||
bonhomme.Angle = Math.PI / 2;
|
||||
bonhomme.jambe1.SetAngle(Math.PI / 2, Math.PI / 2, 0);
|
||||
|
@ -37,20 +41,58 @@ namespace Bonhomme02
|
|||
if(bonhomme.jambe1.Bas.CSG.Y != ySol) // On positionne le bonhomme sur le sol
|
||||
{
|
||||
Graphics gr = Graphics.FromHwnd(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
buff.Render();
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle);
|
||||
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;
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
buff.Render();
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle);
|
||||
}
|
||||
}
|
||||
public void Avancer(int vitesse)
|
||||
public Marcher(ref Bonhomme bonhomme, BufferedGraphics buff, int ySol)
|
||||
{
|
||||
handle = null;
|
||||
step = 0;
|
||||
this.gr = buff.Graphics;
|
||||
this.buff = buff;
|
||||
this.bonhomme = bonhomme;
|
||||
this.handle = null;
|
||||
this.ySol = ySol;
|
||||
resolution = 1;
|
||||
deltaXYmax = (int)Math.Round(3*bonhomme.jambe1.longueur.ABS/4);
|
||||
|
||||
//Reset de tous les angle au cas ou
|
||||
bonhomme.Angle = Math.PI / 2;
|
||||
bonhomme.jambe1.SetAngle(Math.PI / 2, Math.PI / 2, 0);
|
||||
bonhomme.bras.Visible = false;
|
||||
bonhomme.bras.Cacher(gr);
|
||||
if(bonhomme.jambe1.Bas.CSG.Y != ySol) // On positionne le bonhomme sur le sol
|
||||
{
|
||||
bonhomme.Cacher(gr);
|
||||
buff.Render();
|
||||
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();
|
||||
}
|
||||
}
|
||||
public void Avancer()
|
||||
{
|
||||
double old = 1, neww = 0;
|
||||
int dejaDeplacer = 0;
|
||||
while(step<=110 || bonhomme.X <= cooXMax)
|
||||
while(/*step<=110 || */bonhomme.X <= cooXMax)
|
||||
{
|
||||
old = 1; neww = 0;
|
||||
Console.WriteLine(step + "::" + step % 5);
|
||||
|
@ -60,22 +102,44 @@ namespace Bonhomme02
|
|||
case 0:
|
||||
while (dejaDeplacer < deltaXYmax) //Monte jambe 1
|
||||
{
|
||||
bonhomme.Cacher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.jambe1.BougerBas(0, -resolution);
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
dejaDeplacer += resolution;
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 1:
|
||||
while (dejaDeplacer < deltaXYmax)//avence corp + avancer jambe 1 jambe 2 fixe
|
||||
{
|
||||
bonhomme.Cacher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.jambe2.BougerXHaut(resolution, ref bonhomme);
|
||||
bonhomme.jambe1.BougerBas(resolution, 0);
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
dejaDeplacer += resolution;
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
CollerAuSol(ref bonhomme.jambe2); //Voir issues #24
|
||||
|
@ -83,10 +147,22 @@ namespace Bonhomme02
|
|||
case 2:
|
||||
while (bonhomme.jambe1.Bas.CSG.Y < ySol && old != neww) //Descendre jambe 1 sur sol
|
||||
{
|
||||
bonhomme.Cacher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.jambe1.BougerBas(0, resolution);
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
dejaDeplacer += resolution;
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
if (neww != bonhomme.jambe1.Bas.CSG.Y)
|
||||
{
|
||||
|
@ -98,9 +174,18 @@ namespace Bonhomme02
|
|||
|
||||
break;
|
||||
case 3:
|
||||
while (dejaDeplacer < (deltaXYmax*2))//Monte&avance jambe 2,avance bonhome
|
||||
if (bonhomme.jambe2.Bas.X > bonhomme.jambe1.Bas.X)
|
||||
{
|
||||
bonhomme.Cacher(handle);
|
||||
bonhomme.InterevrtirJambe();
|
||||
}
|
||||
while (dejaDeplacer < (deltaXYmax*2))//Monte&avance jambe 2,avance bonhome
|
||||
{
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.jambe1.BougerBas(-resolution, 0);
|
||||
if(dejaDeplacer < deltaXYmax)
|
||||
bonhomme.jambe2.BougerBas(resolution, -resolution);
|
||||
|
@ -114,29 +199,60 @@ namespace Bonhomme02
|
|||
else
|
||||
old = bonhomme.jambe2.Bas.CSG.Y;
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
bonhomme.jambe2.BougerBas(resolution, 0);
|
||||
bonhomme.Coordonnee = new Point(bonhomme.Coordonnee.X + resolution, bonhomme.Coordonnee.Y);
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
dejaDeplacer += resolution;
|
||||
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
while (bonhomme.jambe2.Bas.CSG.Y < ySol - 1 && old != neww)//Descend jambe 2
|
||||
{
|
||||
bonhomme.Cacher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.jambe2.BougerBas(0, resolution);
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
dejaDeplacer += resolution;
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
bonhomme.Cacher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.InterevrtirJambe();// On inverse les deux jambe, jambe1=jambe2 et jambe2=jambe1
|
||||
bonhomme.Afficher(handle);
|
||||
step+=3;
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
step +=3; // retour step 3
|
||||
break;
|
||||
}
|
||||
step++;
|
||||
|
@ -145,21 +261,105 @@ namespace Bonhomme02
|
|||
public void Avancer(int vitesse, int cooX)
|
||||
{
|
||||
this.cooXMax = cooX;
|
||||
Avancer(vitesse);
|
||||
this.vitesse = vitesse;
|
||||
this.step = 0;
|
||||
Avancer();
|
||||
}
|
||||
public void Avancer(int vitesse, int cooX, int startStep)
|
||||
{
|
||||
this.cooXMax = cooX;
|
||||
this.vitesse = vitesse;
|
||||
this.step = startStep;
|
||||
Avancer();
|
||||
}
|
||||
public void CollerAuSol(ref Jambe jambe)
|
||||
{
|
||||
if (jambe.Bas.CSG.Y != ySol) // On positionne le bonhomme sur le sol
|
||||
{
|
||||
Graphics gr = Graphics.FromHwnd(handle);
|
||||
bonhomme.Cacher(handle);
|
||||
//Graphics gr = Graphics.FromHwnd(handle.Value);
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
Point newCoo;
|
||||
int longeurTTBonhome = jambe.Bas.CSG.Y - bonhomme.CIG.Y;// de pied.csg à bonhome.cig
|
||||
newCoo = new Point(bonhomme.Coordonnee.X, ySol - longeurTTBonhome);
|
||||
bonhomme.Coordonnee = newCoo;
|
||||
bonhomme.Afficher(handle);
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
}
|
||||
}
|
||||
public void Saut(ref PictureBox osbtacle, int vitesse)
|
||||
{
|
||||
int marcherJusqa = osbtacle.Location.X - bonhomme.conteneur.Location.X - osbtacle.Height - osbtacle.Width - 4*deltaXYmax;
|
||||
Avancer(vitesse, marcherJusqa);
|
||||
while (bonhomme.Coordonnee.X < osbtacle.Location.X - bonhomme.conteneur.Location.X)//Monter
|
||||
{
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.X += 1;
|
||||
bonhomme.Y -= 1;
|
||||
if(bonhomme.jambe2.Bas.X < bonhomme.jambe1.Bas.X)
|
||||
{
|
||||
bonhomme.InterevrtirJambe();
|
||||
}
|
||||
if(bonhomme.jambe2.Bas.X> bonhomme.jambe1.Bas.X)
|
||||
{
|
||||
bonhomme.jambe2.BougerBas(-resolution, 0);
|
||||
bonhomme.jambe1.BougerBas(resolution, 0);
|
||||
}
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
while (bonhomme.jambe1.Bas.CSG.Y < ySol)//descendre
|
||||
{
|
||||
if(handle == null){
|
||||
bonhomme.Cacher(gr);
|
||||
}
|
||||
else
|
||||
bonhomme.Cacher(handle.Value);
|
||||
bonhomme.X += 1;
|
||||
bonhomme.Y += 1;
|
||||
if (bonhomme.jambe2.Bas.X < bonhomme.jambe1.Bas.X)
|
||||
{
|
||||
bonhomme.InterevrtirJambe();
|
||||
}
|
||||
if (Math.Abs(bonhomme.jambe2.Bas.X - bonhomme.jambe1.Bas.X )< 2*deltaXYmax)
|
||||
{
|
||||
bonhomme.jambe2.BougerBas(resolution, 0);
|
||||
bonhomme.jambe1.BougerBas(-resolution, 0);
|
||||
}
|
||||
if(handle == null){
|
||||
bonhomme.Afficher(gr);
|
||||
}
|
||||
else
|
||||
bonhomme.Afficher(handle.Value);
|
||||
|
||||
if (handle == null)
|
||||
buff.Render();
|
||||
Thread.Sleep(vitesse);
|
||||
}
|
||||
Avancer(vitesse, bonhomme.conteneur.Location.X + bonhomme.conteneur.Width, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Bonhomme02
|
|||
* | * \/ *
|
||||
* | #*****************#
|
||||
* | CSG CSD
|
||||
* |
|
||||
* |
|
||||
* \/
|
||||
* y
|
||||
*/
|
||||
|
@ -93,11 +93,19 @@ namespace Bonhomme02
|
|||
public int X
|
||||
{
|
||||
get { return Coordonnee.X; }
|
||||
set
|
||||
{
|
||||
Coordonnee = new Point(value, Coordonnee.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get { return Coordonnee.Y; }
|
||||
set
|
||||
{
|
||||
Coordonnee = new Point(Coordonnee.X, value);
|
||||
}
|
||||
}
|
||||
public double Angle
|
||||
{
|
||||
|
@ -137,7 +145,7 @@ namespace Bonhomme02
|
|||
if (base.Remplir )
|
||||
{
|
||||
gr.FillClosedCurve(new SolidBrush(base.Fond), l);
|
||||
|
||||
|
||||
}
|
||||
gr.DrawClosedCurve(new Pen(base.Crayon), l);
|
||||
}
|
||||
|
@ -167,6 +175,45 @@ namespace Bonhomme02
|
|||
|
||||
}
|
||||
}
|
||||
public virtual void Afficher(Graphics gr)
|
||||
{
|
||||
if(base.Visible)
|
||||
{
|
||||
try
|
||||
{
|
||||
Point[] l = new Point[4] { CIG, CID, CSD, CSG };
|
||||
if (base.Remplir )
|
||||
{
|
||||
gr.FillClosedCurve(new SolidBrush(base.Fond), l);
|
||||
|
||||
}
|
||||
gr.DrawClosedCurve(new Pen(base.Crayon), l);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void Cacher(Graphics gr)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (base.Visible && 1 == 1)
|
||||
{
|
||||
Point[] l = new Point[4] { CIG, CID, CSD, CSG };
|
||||
if (base.Remplir)
|
||||
{
|
||||
gr.FillClosedCurve(new SolidBrush(base.Hebergeur.BackColor), l);
|
||||
}
|
||||
gr.DrawClosedCurve(new Pen(base.Hebergeur.BackColor), l);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,15 @@ namespace Bonhomme02.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.IO.UnmanagedMemoryStream semblable à System.IO.MemoryStream.
|
||||
/// </summary>
|
||||
internal static System.IO.UnmanagedMemoryStream Super_Mario_Bros_Win_Stage_Sound_Effect {
|
||||
get {
|
||||
return ResourceManager.GetStream("Super_Mario_Bros_Win_Stage_Sound_Effect", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une ressource localisée de type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -124,6 +124,9 @@
|
|||
<data name="NyanCatoriginal" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NyanCatoriginal.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="Super_Mario_Bros_Win_Stage_Sound_Effect" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Super Mario Bros Win Stage Sound Effect.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="tumblr_opsismTLqh1vghf22o1_400" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\tumblr_opsismTLqh1vghf22o1_400.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
|
|
@ -51,6 +51,32 @@ namespace Bonhomme02
|
|||
gr.DrawEllipse(new Pen(Brushes.Black), posi.X, posi.Y, rayon * 2, rayon * 2);
|
||||
}
|
||||
}
|
||||
public void Cacher(Graphics gr)
|
||||
{
|
||||
Point posi = new Point(corp.coordonnee.X - rayon, corp.coordonnee.Y - rayon * 2);
|
||||
if (base.Visible)
|
||||
{
|
||||
if (base.Remplir)
|
||||
{
|
||||
gr.FillEllipse(new SolidBrush(base.Hebergeur.BackColor), posi.X, posi.Y, rayon * 2, rayon * 2);
|
||||
}
|
||||
gr.DrawEllipse(new Pen(base.Hebergeur.BackColor), posi.X, posi.Y, rayon * 2, rayon * 2);
|
||||
}
|
||||
}
|
||||
public void Afficher(Graphics gr)
|
||||
{
|
||||
|
||||
if (base.Visible)
|
||||
{
|
||||
|
||||
Point posi = new Point(corp.coordonnee.X - rayon, corp.coordonnee.Y - rayon * 2);
|
||||
if (base.Remplir)
|
||||
{
|
||||
gr.FillEllipse(new SolidBrush(base.Fond), posi.X, posi.Y, rayon * 2, rayon * 2);
|
||||
}
|
||||
gr.DrawEllipse(new Pen(Brushes.Black), posi.X, posi.Y, rayon * 2, rayon * 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue