/**
 * Check if any game objects have collided with each other.
 *
 * @param gameObjects A list containing the game objects.
 * @return A list of collided game objects.
 */
fun checkCollision(gameObjects: List<Pair<IntArray, IntArray>>): List<Pair<IntArray, IntArray>> {

    val collidedObjects = mutableListOf<Pair<IntArray, IntArray>>()

    for (i in gameObjects.indices) {
        for (j in i + 1 until gameObjects.size) {
            val obj1 = gameObjects[i]
            val obj2 = gameObjects[j]

            // Check if both objects are within the same region
            if ((obj1.first[0] <= obj2.first[0] && obj2.first[0] <= obj1.first[2]) ||
                (obj2.first[0] <= obj1.first[0] && obj1.first[0] <= obj2.first[2])
            ) {
                if ((obj1.first[1] <= obj2.first[1] && obj2.first[1] <= obj1.first[3]) ||
                    (obj2.first[1] <= obj1.first[1] && obj1.first[1] <= obj2.first[3])
                ) {
                    collidedObjects.add(Pair(obj1.first, obj2.first))
                }
            }
        }
    }

    return collidedObjects
}
/**
 * Check if any game objects have collided with each other.
 *
 * @param gameObjects A list containing the game objects.
 * @return A list of collided game objects.
 */
fun checkCollision(gameObjects: List<Pair<IntArray, IntArray>>): List<Pair<IntArray, IntArray>> {
/**
 * Check if any game objects have collided with each other.
 *
 * @param gameObjects A list containing the game objects.
 * @return A list of collided game objects.
 */
fun checkCollision(gameObjects: List<Pair<IntArray, IntArray>>): List<Pair<IntArray, IntArray>> {

    val collidedObjects = mutableListOf<Pair<IntArray, IntArray>>()

    for (i in gameObjects.indices) {
        for (j in i + 1 until gameObjects.size) {
            val obj1 = gameObjects[i]
            val obj2 = gameObjects[j]

            // Check if both objects are within the same region
            if ((obj1.first[0] <= obj2.first[0] && obj2.first[0] <= obj1.first[2]) ||
                (obj2.first[0] <= obj1.first[0] && obj1.first[0] <= obj2.first[2])
            ) {
                if ((obj1.first[1] <= obj2.first[1] && obj2.first[1] <= obj1.first[3]) ||
                    (obj2.first[1] <= obj1.first[1] && obj1.first[1] <= obj2.first[3])
                ) {
                    collidedObjects.add(Pair(obj1.first, obj2.first))
                }
            }
        }
    }

    return collidedObjects
}