Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // stupid function
- public int GetCurrGrid(int x, int y)
- {
- // x - horisont
- // y - vertical
- /* 0 1 2 3
- * 4 5 6 7
- * 8 9 10 11
- * 12 13 14 15
- */
- int res = 0;
- // hardcore - how to optimize?
- if (x <= 100)
- {
- if (y < 100)
- res = 0;
- else if (y >= 100 && y < 200)
- res = 4;
- else if (y >= 200 && y < 300)
- res = 8;
- else if (y >= 300)
- res = 12;
- } else if (x >= 100)
- {
- if (y < 100)
- res = 1;
- else if (y >= 100 && y < 200)
- res = 5;
- else if (y >= 200 && y < 300)
- res = 9;
- else if (y >= 300)
- res = 13;
- } else if (x >= 200)
- {
- if (y < 100)
- res = 2;
- else if (y >= 100 && y < 200)
- res = 6;
- else if (y >= 200 && y < 300)
- res = 10;
- else if (y >= 300)
- res = 14;
- } else if (x >= 300)
- {
- if (y < 100)
- res = 3;
- else if (y >= 100 && y < 200)
- res = 7;
- else if (y >= 200 && y < 300)
- res = 11;
- else if (y >= 300)
- res = 15;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement