Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. // stupid function
  2. public int GetCurrGrid(int x, int y)
  3. {
  4. // x - horisont
  5. // y - vertical
  6. /* 0 1 2 3
  7. * 4 5 6 7
  8. * 8 9 10 11
  9. * 12 13 14 15
  10. */
  11. int res = 0;
  12. // hardcore - how to optimize?
  13. if (x <= 100)
  14. {
  15. if (y < 100)
  16. res = 0;
  17. else if (y >= 100 && y < 200)
  18. res = 4;
  19. else if (y >= 200 && y < 300)
  20. res = 8;
  21. else if (y >= 300)
  22. res = 12;
  23. } else if (x >= 100)
  24. {
  25. if (y < 100)
  26. res = 1;
  27. else if (y >= 100 && y < 200)
  28. res = 5;
  29. else if (y >= 200 && y < 300)
  30. res = 9;
  31. else if (y >= 300)
  32. res = 13;
  33. } else if (x >= 200)
  34. {
  35. if (y < 100)
  36. res = 2;
  37. else if (y >= 100 && y < 200)
  38. res = 6;
  39. else if (y >= 200 && y < 300)
  40. res = 10;
  41. else if (y >= 300)
  42. res = 14;
  43. } else if (x >= 300)
  44. {
  45. if (y < 100)
  46. res = 3;
  47. else if (y >= 100 && y < 200)
  48. res = 7;
  49. else if (y >= 200 && y < 300)
  50. res = 11;
  51. else if (y >= 300)
  52. res = 15;
  53. }
  54. return res;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement