Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Reperage(float mvtx, float mvty, float destinationx, float destinationy, int speed, int persovit, int Rayon, int persotaille)
- {
- {
- Fantomebullet fantomebullet;
- fantomebullet = new Fantomebullet();
- float deltaX = (mvtx - destinationx); //calcul distance entre les deux instances en X
- float deltaY = (mvty - destinationy); //En Y
- int nstep = Rayon / fantomebullet.balleSpeed;
- int dpJoueurMax = nstep * persovit;
- int nballe = dpJoueurMax / (persotaille-2); //marge d'erreur 2px
- double Alpha = Math.Atan2(deltaY,deltaX);
- double HYP = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
- double Beta = Math.Atan2(HYP, dpJoueurMax);
- double deltaZ = (Alpha + Beta) - (Alpha - Beta);
- double Aincrementer = deltaZ / nballe;
- for(double i2 = Alpha-Beta; i2 <= (Alpha+Beta); i2+= Aincrementer )
- {
- fantomebullet.position = new Vector2(mvtx, mvty);
- fantomebullet.balleVitesse = new Vector2(Convert.ToSingle(Math.Cos(i2)) * -speed, Convert.ToSingle(Math.Sin(i2)) * -speed);
- lstfballe.Add(fantomebullet);
- for (int i = lstfballe.Count - 1; i >= 0; i--)
- {
- fantomebullet = lstfballe[i];
- if (fantomebullet.isRemoved == true)
- {
- lstfballe.Remove(fantomebullet);
- }
- }
- retir = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement