/**
 * This function checks if any game objects collide with the given x and y ranges.
 *
 * @param gameObjects A list of game objects.
 * @param xRange A Pair representing the x range to check for collision.
 * @param yRange A Pair representing the y range to check for collision.
 * @return A list of game objects that collide with the given ranges.
 */
fun gameObjectCollision(gameObjects: List<Map<String, Int>>, xRange: Pair<Int, Int>, yRange: Pair<Int, Int>): List<Map<String, Int>> {

    val collidedObjects = mutableListOf<Map<String, Int>>()

    // Iterate over each game object
    for (gameObject in gameObjects) {
        // Get the x and y values of the game object
        val xValue = gameObject["x"] ?: 0
        val yValue = gameObject["y"] ?: 0

        // Skip the game object if it's outside the x range
        if (xValue < xRange.first || xValue > xRange.second) {
            continue
        }

        // Skip the game object if it's outside the y range
        if (yValue < yRange.first || yValue > yRange.second) {
            continue
        }

        // Add the game object to the collidedObjects list
        collidedObjects.add(gameObject)
    }

    return collidedObjects
}
/**
 * This function checks if any game objects collide with the given x and y ranges.
 *
 * @param gameObjects A list of game objects.
 * @param xRange A Pair representing the x range to check for collision.
 * @param yRange A Pair representing the y range to check for collision.
 * @return A list of game objects that collide with the given ranges.
 */
fun gameObjectCollision(gameObjects: List<Map<String, Int>>, xRange: Pair<Int, Int>, yRange: Pair<Int, Int>): List<Map<String, Int>> {
/**
 * This function checks if any game objects collide with the given x and y ranges.
 *
 * @param gameObjects A list of game objects.
 * @param xRange A Pair representing the x range to check for collision.
 * @param yRange A Pair representing the y range to check for collision.
 * @return A list of game objects that collide with the given ranges.
 */
fun gameObjectCollision(gameObjects: List<Map<String, Int>>, xRange: Pair<Int, Int>, yRange: Pair<Int, Int>): List<Map<String, Int>> {

    val collidedObjects = mutableListOf<Map<String, Int>>()

    // Iterate over each game object
    for (gameObject in gameObjects) {
        // Get the x and y values of the game object
        val xValue = gameObject["x"] ?: 0
        val yValue = gameObject["y"] ?: 0

        // Skip the game object if it's outside the x range
        if (xValue < xRange.first || xValue > xRange.second) {
            continue
        }

        // Skip the game object if it's outside the y range
        if (yValue < yRange.first || yValue > yRange.second) {
            continue
        }

        // Add the game object to the collidedObjects list
        collidedObjects.add(gameObject)
    }

    return collidedObjects
}