多年来,我一直在进行网络开发,我慢慢慢慢地亲自参与游戏发展,而对于我目前的项目,我已经走过这个非对称地图,在那里,我需要使用算法来探测哪些领域正在被点击。 所有这一切都是用 way字进行的。
The map
It looks like this and I ve added some numbers to show you the structure of the fields (tiles) and their IDs. All the fields have a center point (array of x,y) which the four corners are based on when drawn.
As you can see it s not a diamond shape, but a zig-zag map and there s no angle (top-down view) which is why I can t find an answer myself considering that all articles and calculations are usually based on a diamond shape with an angle.
The numbers
It s a dynamic map and all sizes and numbers can be changed to generate a new map.
I know it isn t a lot of data, but the map is generated based on the map and field sizes.
- Map Size: x:800 y:400
- Field Size: 80x80 (between corners)
- Center position of all the fields (x,y)
The goal
To come up with an algorithm which tells the client (game) which field the mouse is located in at any given event (click, movement etc).
Disclaimer
I do want to mention that I ve already come up with a working solution myself, however I m 100% certain it could be written in a better way (my solution involves a lot of nested if-statements and loops), and that s why I m asking here.
https://i.stack.imgur.com/h8zRjpg”rel=“nofollow”> 在此,是我解决办法的一个实例,我基本上在最接近的4个已知职位中找到一个角逐点,然后根据最接近的2个领域之间的最小平方得出我的结果。 这是否有意义?
如果我错了。