https://github.com/maxvol/gameplaykitdsl
Swift DSL for constructing GameplayKit objects.
https://github.com/maxvol/gameplaykitdsl
dsl gameplaykit swift
Last synced: 4 months ago
JSON representation
Swift DSL for constructing GameplayKit objects.
- Host: GitHub
- URL: https://github.com/maxvol/gameplaykitdsl
- Owner: maxvol
- License: mit
- Created: 2019-01-30T20:32:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-31T04:24:21.000Z (about 4 years ago)
- Last Synced: 2025-02-27T09:57:56.729Z (7 months ago)
- Topics: dsl, gameplaykit, swift
- Language: Swift
- Size: 27.3 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GameplayKitDSL
Swift DSL for constructing GameplayKit objects.```swift
let agent = GKAgent.agent2D {
$0.radius = 10
$0.maxSpeed = 100
$0.maxAcceleration = 50
}
``````swift
let behavior = GKBehavior.behavior {
$0.setWeight(50, for: Goal.wander)
$0.setWeight(50, for: Goal.avoid)
}
``````swift
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
}
}```
```swift
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)
}
]
```