Advertisement
Guest User

C code hahahahahahaha

a guest
Jan 25th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. void Heading(int Jstick, int x, int y, int *hX, int *hY){
  2.  
  3. if(y > Jstick/2+2){
  4. *hY = 1;
  5. }else if(y < Jstick/2-2){
  6. *hY = -1;
  7. }else{
  8. *hY = 0;
  9. }
  10.  
  11.  
  12. if(x > Jstick/2+2){
  13. *hX = 1;
  14. }else if(x < Jstick/2-2){
  15. *hX = -1;
  16. }else{
  17. *hX = 0;
  18. }
  19.  
  20.  
  21. }
  22.  
  23. int main()
  24. {
  25.  
  26.  
  27.  
  28.  
  29. int Jstick = 4095;
  30. double div = Jstick/200.0;
  31. int x, y;
  32. int hX, hY;
  33.  
  34. while(1){
  35.  
  36. scanf("%d %d", &x, &y);
  37. x = (x-Jstick/2)/div;
  38. y = (y-Jstick/2)/div;
  39.  
  40. Heading(Jstick, x, y, &hX, &hY);
  41.  
  42. printf("\nx is %d\ny is %d", x, y);
  43.  
  44.  
  45. }
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement