Swiftpack.co - maxvol/GameplayKitDSL as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by maxvol.
maxvol/GameplayKitDSL 0.1.0
Swift DSL for constructing GameplayKit objects.
⭐️ 4
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/maxvol/GameplayKitDSL.git", from: "0.1.0")

GameplayKitDSL

Swift DSL for constructing GameplayKit objects.

let agent = GKAgent.agent2D {
                $0.radius = 10
                $0.maxSpeed = 100
                $0.maxAcceleration = 50
            }
let behavior = GKBehavior.behavior {
        $0.setWeight(50, for: Goal.wander)
        $0.setWeight(50, for: Goal.avoid)
    }
let spriteEntity = GKEntity.entity { entity in
    entity.skNodeComponent {
        $0.node = sprite
    }
    entity.agent2D { agent in
        agent.delegate = entity.components.filter { $0 is GKSKNodeComponent }.first? as? GKSKNodeComponent
    }
}

let obstacles = [
        GKObstacle.circle(radius: 50) {
            $0.position = vector_float2(-100, -100)
        },
        GKObstacle.circle(radius: 50) {
            $0.position = vector_float2(-100, 100)
        },
        GKObstacle.circle(radius: 50) {
            $0.position = vector_float2(100, -100)
        },
        GKObstacle.circle(radius: 50) {
            $0.position = vector_float2(100, 100)
        }
    ]

GitHub

link
Stars: 4
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swift 5
4 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics