Types
CollisionPoint {.importc: "CollisionPoint", header: "pd_api.h", bycopy.} = object x* {.importc: "x".}: cfloat y* {.importc: "y".}: cfloat
CollisionVector {.importc: "CollisionVector", header: "pd_api.h", bycopy.} = object x* {.importc: "x".}: cint y* {.importc: "y".}: cint
PDRect {.importc: "PDRect", header: "pd_api.h", bycopy.} = object x* {.importc: "x".}: cfloat y* {.importc: "y".}: cfloat width* {.importc: "width".}: cfloat height* {.importc: "height".}: cfloat
PlaydateSprite {.importc: "const struct playdate_sprite", header: "pd_api.h", bycopy.} = object addDirtyRect* {.importc: "addDirtyRect".}: proc (dirtyRect: LCDRect) {.cdecl, ...raises: [].} drawSprites* {.importc: "drawSprites".}: proc () {.cdecl, ...raises: [].} updateAndDrawSprites* {.importc: "updateAndDrawSprites".}: proc () {.cdecl, ...raises: [].} ## Collisions resetCollisionWorld* {.importc: "resetCollisionWorld".}: proc () {.cdecl, ...raises: [].} ## Caller is responsible for freeing the returned array for all collision methods ## Added in 1.7 ## Added in 1.10 ## added in 2.1
SpriteCollisionInfo {.importc: "SpriteCollisionInfo", header: "pd_api.h", bycopy.} = object ## The sprite being moved ## The sprite colliding with the sprite being moved responseType* {.importc: "responseType".}: SpriteCollisionResponseType ## The result of collisionResponse overlaps* {.importc: "overlaps".}: uint8 ## True if the sprite was overlapping other when the collision started. False if it didn’t overlap but tunneled through other. ti* {.importc: "ti".}: cfloat ## A number between 0 and 1 indicating how far along the movement to the goal the collision occurred move* {.importc: "move".}: CollisionPoint ## The difference between the original coordinates and the actual ones when the collision happened normal* {.importc: "normal".}: CollisionVector ## The collision normal; usually -1, 0, or 1 in x and y. Use this value to determine things like if your character is touching the ground. touch* {.importc: "touch".}: CollisionPoint ## The coordinates where the sprite started touching other spriteRect* {.importc: "spriteRect".}: PDRect ## The rectangle the sprite occupied when the touch happened otherRect* {.importc: "otherRect".}: PDRect ## The rectangle the sprite being collided with occupied when the touch happened
SpriteCollisionResponseType {.size: 4, importc: "SpriteCollisionResponseType".} = enum kCollisionTypeSlide, kCollisionTypeFreeze, kCollisionTypeOverlap, kCollisionTypeBounce
SpriteQueryInfo {.importc: "SpriteQueryInfo", header: "pd_api.h", bycopy.} = object sprite* {.importc: "sprite".}: LCDSpritePtr ## The sprite being intersected by the segment ## ti1 and ti2 are numbers between 0 and 1 which indicate how far from the starting point of the line segment the collision happened ti1* {.importc: "ti1".}: cfloat ## entry point ti2* {.importc: "ti2".}: cfloat ## exit point entryPoint* {.importc: "entryPoint".}: CollisionPoint ## The coordinates of the first intersection between sprite and the line segment exitPoint* {.importc: "exitPoint".}: CollisionPoint ## The coordinates of the second intersection between sprite and the line segment
Procs
proc getSpriteCount(this: ptr PlaydateSprite): int {....raises: [], tags: [RootEffect], forbids: [].}
proc PDRectMake(x: cfloat; y: cfloat; width: cfloat; height: cfloat): PDRect {. inline, cdecl, importc: "PDRectMake", ...raises: [], tags: [], forbids: [].}