Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. public void Reperage(float mvtx, float mvty, float destinationx, float destinationy, int speed, int persovit, int Rayon, int persotaille)
  2. {
  3. {
  4. Fantomebullet fantomebullet;
  5. fantomebullet = new Fantomebullet();
  6.  
  7. float deltaX = (mvtx - destinationx); //calcul distance entre les deux instances en X
  8. float deltaY = (mvty - destinationy); //En Y
  9.  
  10. int nstep = Rayon / fantomebullet.balleSpeed;
  11. int dpJoueurMax = nstep * persovit;
  12. int nballe = dpJoueurMax / (persotaille-2); //marge d'erreur 2px
  13.  
  14. double Alpha = Math.Atan2(deltaY,deltaX);
  15. double HYP = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
  16. double Beta = Math.Atan2(HYP, dpJoueurMax);
  17.  
  18. double deltaZ = (Alpha + Beta) - (Alpha - Beta);
  19. double Aincrementer = deltaZ / nballe;
  20.  
  21. for(double i2 = Alpha-Beta; i2 <= (Alpha+Beta); i2+= Aincrementer )
  22. {
  23. fantomebullet.position = new Vector2(mvtx, mvty);
  24. fantomebullet.balleVitesse = new Vector2(Convert.ToSingle(Math.Cos(i2)) * -speed, Convert.ToSingle(Math.Sin(i2)) * -speed);
  25. lstfballe.Add(fantomebullet);
  26.  
  27.  
  28.  
  29. for (int i = lstfballe.Count - 1; i >= 0; i--)
  30. {
  31. fantomebullet = lstfballe[i];
  32. if (fantomebullet.isRemoved == true)
  33. {
  34. lstfballe.Remove(fantomebullet);
  35. }
  36. }
  37. retir = false;
  38. }
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement