Tete Ok, deplacement corp Ok
This commit is contained in:
		@@ -22,14 +22,19 @@ namespace Bonhomme02
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public BaseBJ(PictureBox Hebergeur, ref Peau parent, Peau bas, double longueur, double epaisseur, double angle)
 | 
			
		||||
        public BaseBJ(PictureBox Hebergeur, ref Peau parent, Peau bas, double longueur, double epaisseur, double angle) : this( Hebergeur,  ref parent,  longueur,  epaisseur,  angle)
 | 
			
		||||
        {
 | 
			
		||||
            this.Bas = bas;
 | 
			
		||||
            this.Bas.parent = this.Millieux;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public BaseBJ(PictureBox Hebergeur, ref Peau parent, double longueur, double epaisseur, double angle)
 | 
			
		||||
        {
 | 
			
		||||
            this.parent = parent;
 | 
			
		||||
            this.longueur = longueur;
 | 
			
		||||
            this.Haut = new Peau(Hebergeur, ref parent, longueur/2, epaisseur, angle);
 | 
			
		||||
            this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur/2, epaisseur, angle);
 | 
			
		||||
            this.Bas = bas;
 | 
			
		||||
            this.Bas.parent = this.Millieux;
 | 
			
		||||
            this.Haut = new Peau(Hebergeur, ref parent, longueur / 2, epaisseur, angle);
 | 
			
		||||
            this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur / 2, epaisseur, angle);
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
        public void Afficher(IntPtr handle)
 | 
			
		||||
        {
 | 
			
		||||
@@ -57,41 +62,44 @@ namespace Bonhomme02
 | 
			
		||||
        }
 | 
			
		||||
        public Point TouverPointMillieux(Point bas)
 | 
			
		||||
        {
 | 
			
		||||
            Point H = Haut.Coordonnee;
 | 
			
		||||
            //Point M = new Point() ;    //Inconnue
 | 
			
		||||
            Point B = new Point(bas.X-H.X, bas.Y-H.Y); //On part du principe que H est 0;0
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                Point H = Haut.Coordonnee;
 | 
			
		||||
                //Point M = new Point() ;    //Inconnue
 | 
			
		||||
                Point B = new Point(bas.X - H.X, bas.Y - H.Y); //On part du principe que H est 0;0
 | 
			
		||||
 | 
			
		||||
            Complex tt = new Complex(B.X, B.Y);
 | 
			
		||||
                Complex tt = new Complex(B.X, B.Y);
 | 
			
		||||
 | 
			
		||||
            double a = Math.Sqrt(4 * Math.Pow(Haut.longueur.ABS, 2) - Math.Pow(B.X, 2) - Math.Pow(B.Y, 2));
 | 
			
		||||
            double b = Math.Sqrt(Math.Pow(B.X, 2) + Math.Pow(B.Y, 2));
 | 
			
		||||
                double a = Math.Sqrt(4 * Math.Pow(Haut.longueur.ABS, 2) - Math.Pow(B.X, 2) - Math.Pow(B.Y, 2));
 | 
			
		||||
                double b = Math.Sqrt(Math.Pow(B.X, 2) + Math.Pow(B.Y, 2));
 | 
			
		||||
 | 
			
		||||
            double cooMX = (B.Y * a + B.X * b);
 | 
			
		||||
                cooMX /= 2*b;
 | 
			
		||||
            double cooMY = -(B.X * a - B.Y * b);
 | 
			
		||||
            cooMY /= 2 * b;
 | 
			
		||||
                double cooMX = (B.Y * a + B.X * b);
 | 
			
		||||
                cooMX /= 2 * b;
 | 
			
		||||
                double cooMY = -(B.X * a - B.Y * b);
 | 
			
		||||
                cooMY /= 2 * b;
 | 
			
		||||
 | 
			
		||||
            Complex t = new Complex(cooMX, cooMY);
 | 
			
		||||
            cooMX += H.X;
 | 
			
		||||
            cooMY += H.Y;
 | 
			
		||||
            int xx = (int)Math.Round(cooMX);
 | 
			
		||||
            int yy = (int)Math.Round(cooMY);
 | 
			
		||||
            return new Point(xx, yy);
 | 
			
		||||
                Complex t = new Complex(cooMX, cooMY);
 | 
			
		||||
                cooMX += H.X;
 | 
			
		||||
                cooMY += H.Y;
 | 
			
		||||
                int xx = (int)Math.Round(cooMX);
 | 
			
		||||
                int yy = (int)Math.Round(cooMY);
 | 
			
		||||
                return new Point(xx, yy);
 | 
			
		||||
            }
 | 
			
		||||
            catch(Exception e)
 | 
			
		||||
            {
 | 
			
		||||
                Console.WriteLine("Erreur Point millieux : " + e);
 | 
			
		||||
                return new Point(0, 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public void Bouger(int X, int Y)
 | 
			
		||||
        {
 | 
			
		||||
            Point nouveauPtBas = new Point(Bas.X + X, Bas.Y + Y);
 | 
			
		||||
            Point nouveauPtMillieux = TouverPointMillieux(nouveauPtBas);
 | 
			
		||||
            if(nouveauPtMillieux.X == 0 && nouveauPtMillieux.Y == 0)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            if(nouveauPtMillieux.X != 0 || nouveauPtMillieux.Y != 0)
 | 
			
		||||
            {
 | 
			
		||||
                Haut.Angle = TrouverAngleHaut(nouveauPtMillieux);
 | 
			
		||||
                Millieux.Angle = TrouverAngleMillieux(nouveauPtBas);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            }            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,19 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Bonhomme02
 | 
			
		||||
{
 | 
			
		||||
    class Bras : BaseBJ
 | 
			
		||||
    {
 | 
			
		||||
        public Bras()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public Bras(PictureBox Hebergeur, ref Peau parent, double longueur, double epaisseur, double angle) : base( Hebergeur, ref  parent,  longueur,  epaisseur,  angle)
 | 
			
		||||
        {
 | 
			
		||||
            base.Bas = new Pied(Hebergeur, ref base.Millieux, longueur * 0.3125, epaisseur, 0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ namespace Bonhomme02
 | 
			
		||||
        private BaseBJ jambe;
 | 
			
		||||
        private Pied pied;
 | 
			
		||||
        private Peau corp;
 | 
			
		||||
        Tete tete;
 | 
			
		||||
        private BufferedGraphics bufferG = null;
 | 
			
		||||
        private Graphics g;
 | 
			
		||||
 | 
			
		||||
@@ -36,9 +37,14 @@ namespace Bonhomme02
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                corp.Cacher(this.TV.Handle);
 | 
			
		||||
                tete.Cacher(this.TV.Handle);
 | 
			
		||||
                jambe.Cacher(this.TV.Handle);
 | 
			
		||||
                corp.coordonnee = new Point(corp.coordonnee.X + 3, corp.coordonnee.Y + 0);
 | 
			
		||||
                jambe.Bouger(+3, -3);
 | 
			
		||||
                jambe.Afficher(this.TV.Handle);
 | 
			
		||||
                corp.Afficher(this.TV.Handle);
 | 
			
		||||
                tete.Afficher(this.TV.Handle);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -59,11 +65,13 @@ namespace Bonhomme02
 | 
			
		||||
 | 
			
		||||
            corp = new Peau(this.TV, 80, 80, 100, 40, Math.PI / 2);
 | 
			
		||||
            pied = new Pied(this.TV, 25, 10, 0);
 | 
			
		||||
            jambe = new BaseBJ(this.TV, ref corp, pied, 80, 10, Math.PI / 2);
 | 
			
		||||
            jambe = new Jambe(this.TV, ref corp, 100, 10, Math.PI / 2);
 | 
			
		||||
            tete = new Tete(this.TV, ref corp, 35);
 | 
			
		||||
            jambe.Haut.Angle = Math.PI/4;
 | 
			
		||||
            jambe.Millieux.Angle = Math.PI/2 + Math.PI/8 ;
 | 
			
		||||
            jambe.Afficher(this.TV.Handle);
 | 
			
		||||
            corp.Afficher(this.TV.Handle);
 | 
			
		||||
            tete.Afficher(this.TV.Handle);
 | 
			
		||||
            this.btnStopDeplacerCTick.Enabled = true;
 | 
			
		||||
            this.timerImage.Start();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,21 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Bonhomme02
 | 
			
		||||
{
 | 
			
		||||
    class Jambe : BaseBJ
 | 
			
		||||
    {
 | 
			
		||||
        /*pied = new Pied(this.TV, 25, 10, 0);
 | 
			
		||||
        jambe = new BaseBJ(this.TV, ref corp, pied, 80, 10, Math.PI / 2);*/
 | 
			
		||||
        public Jambe()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public Jambe(PictureBox Hebergeur, ref Peau parent, double longueur, double epaisseur, double angle) : base( Hebergeur, ref  parent,  longueur,  epaisseur,  angle)
 | 
			
		||||
        {
 | 
			
		||||
            base.Bas = new Pied(Hebergeur,ref base.Millieux, longueur*0.3125, epaisseur, 0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,7 @@ namespace Bonhomme02
 | 
			
		||||
        {
 | 
			
		||||
            base.longueur = new Vecteur(lg, angle);
 | 
			
		||||
            base.epaisseur = new Vecteur(ep, ref base.longueur, true);
 | 
			
		||||
            talon = new Vecteur(lg / 2, angle);
 | 
			
		||||
            talon = new Vecteur(lg / 3, angle);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,78 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Bonhomme02
 | 
			
		||||
{
 | 
			
		||||
    class Tete
 | 
			
		||||
    class Tete : BaseDessin
 | 
			
		||||
    {
 | 
			
		||||
        public int rayon;
 | 
			
		||||
        Peau corp;
 | 
			
		||||
        public Tete() : base()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Tete(PictureBox hebergeur, ref Peau corp, int rayon) : base(hebergeur)
 | 
			
		||||
        {
 | 
			
		||||
            this.rayon = rayon;
 | 
			
		||||
            this.corp = corp;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Tete(PictureBox hebergeur, int xy) : base(hebergeur, xy)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Tete(PictureBox hebergeur, int x, int y) : base(hebergeur, x, y)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public Tete(int x, int y) : base(x, y)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public Tete(PictureBox hebergeur, int xy, Color crayon) : base(hebergeur, xy, crayon)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Tete(PictureBox hebergeur, int x, int y, Color crayon) : base(hebergeur, x, y, crayon)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        public override void Cacher(IntPtr handle)
 | 
			
		||||
        {
 | 
			
		||||
            Point posi = new Point(corp.coordonnee.X - rayon, corp.coordonnee.Y - rayon * 2);
 | 
			
		||||
            if (base.Visible)
 | 
			
		||||
            {
 | 
			
		||||
                Graphics gr = Graphics.FromHwnd(handle);
 | 
			
		||||
                
 | 
			
		||||
                if (base.Remplir)
 | 
			
		||||
                {
 | 
			
		||||
                    gr.FillEllipse(new SolidBrush(base.Fond), posi.X , posi.Y, rayon*2, rayon*2);
 | 
			
		||||
                }
 | 
			
		||||
                gr.DrawEllipse(new Pen(base.Fond), posi.X, posi.Y, rayon*2, rayon*2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public override void Afficher(IntPtr handle)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            if (base.Visible)
 | 
			
		||||
            {
 | 
			
		||||
                Graphics gr = Graphics.FromHwnd(handle);
 | 
			
		||||
                Point posi = new Point(corp.coordonnee.X - rayon , corp.coordonnee.Y - rayon * 2);
 | 
			
		||||
                if (base.Remplir)
 | 
			
		||||
                {
 | 
			
		||||
                    gr.FillEllipse(new SolidBrush(Color.Blue), posi.X, posi.Y, rayon * 2, rayon * 2);
 | 
			
		||||
                }
 | 
			
		||||
                gr.DrawEllipse(new Pen(Brushes.Black), posi.X, posi.Y, rayon * 2, rayon * 2);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user