大佬教程收集整理的这篇文章主要介绍了如何计算两个矩形之间的距离? (上下文:Lua中的一个游戏),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
背景:在一个用Lua写的游戏中,我随机生成地图,但是要确保某些矩形彼此不太近 – 这是需要的,因为如果矩形进入某个近距离位置,地图变得无法解决,因为一个球需要通过它们之间.速度不是一个巨大的问题,因为我没有很多矩形,地图只是每级生成一次.我在StackOverflow上发现的以前的链接是this和this
提前谢谢了!
(1) check if the rects intersect. If so,the distance between them is 0. (2) If not,think of r2 as the center of a telephone key pad,#5. (3) r1 may be fully in one of the extreme quadrants (#1,#3,#7,or #9). If so the distance is the distance from one rect corner to another (e.g.,if r1 is in quadrant #1,the distance is the distance from the lower-right corner of r1 to the upper-left corner of r2). (4) Otherwise r1 is to the left,right,above,or below r2 and the distance is the distance between the relevant sides (e.g.,if r1 is above,the distance is the distance between r1's low y and r2's high y).
以上是大佬教程为你收集整理的如何计算两个矩形之间的距离? (上下文:Lua中的一个游戏)全部内容,希望文章能够帮你解决如何计算两个矩形之间的距离? (上下文:Lua中的一个游戏)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。