在java中的方块碰撞算法 [英] Collision algorithm in java for squares
问题描述
所以我做了一个简单和轻松的比赛,我需要检测2盒之间的碰撞。它只需要返回一个true或类似的东西,没有物理介入。
so I'm making a simple and easy game and I need to detect the collision between 2 boxes. It only needs to return a true or something like that, no physics involved.
于是我就开始工作,但没有找到一个算法,将检查碰撞的转身广场。
So I started working and couldn't find an algorithm that would check the collision for turned squares.
Here I visualized the problem.
因此,大家可以看到广场1,2和3将返回true,因为它们与绿色方块相撞。 4将返回false因为它没有发生碰撞。
So as you can see squares 1,2 and 3 would return true because they collided with the green squares. 4 would return false because it isn't colliding.
我有两种颜色在不同的数组列表中所有的方块。
I do have all the squares of both colors in separate array lists.
是否有人知道一个lib或算法,这个问题?在此先感谢:)
Does anybody know a lib or algorithm for this problem? Thanks in advance :)
推荐答案
退房区类中的java.awt.geom包。
Check out the Area class in the java.awt.geom package.
http://docs.oracle。 COM / JavaSE的/ 6 /文档/ API /爪哇/ AWT / GEOM / Area.html
这篇关于在java中的方块碰撞算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!