Swift 6.4 migration and exhancements (#1)
This PR contains the work done to update the library and the attached example project to use the Swift 6.4 computer as a minimum supported version and also, to use the latest features introduced in it. Reviewed-on: #1 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Sprite {
|
||||
/// Information about a single collision, mirroring `SpriteCollisionInfo`.
|
||||
/// A single collision. Wraps `SpriteCollisionInfo`.
|
||||
public struct CollisionInfo {
|
||||
/// The sprite being moved.
|
||||
public let sprite: Sprite
|
||||
/// The sprite it collided with.
|
||||
public let other: Sprite
|
||||
/// The collision response used.
|
||||
public let response: CollisionResponse
|
||||
/// `true` if the sprites were overlapping when the collision
|
||||
/// started; `false` if the sprite tunneled through.
|
||||
/// `true` if already overlapping `other` at the start; `false` if it tunneled through.
|
||||
public let overlaps: Bool
|
||||
/// How far along the movement (0...1) the collision occurred.
|
||||
/// Fraction of the move to the goal done at the collision, 0...1.
|
||||
public let ti: Float
|
||||
/// The difference between the requested and actual positions.
|
||||
/// Difference between the original and actual positions at the collision.
|
||||
public let move: (x: Float, y: Float)
|
||||
/// The collision normal (each component -1, 0, or 1).
|
||||
/// Components usually -1, 0, or 1.
|
||||
public let normal: (x: Int, y: Int)
|
||||
/// Where the sprite started touching `other`.
|
||||
/// Where `sprite` started touching `other`.
|
||||
public let touch: (x: Float, y: Float)
|
||||
/// The sprite's rect at the moment of the touch.
|
||||
/// `sprite`'s rect at the touch.
|
||||
public let spriteRect: Rect
|
||||
/// `other`'s rect at the moment of the touch.
|
||||
/// `other`'s rect at the touch.
|
||||
public let otherRect: Rect
|
||||
|
||||
init(_ info: SpriteCollisionInfo) {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
internal import CPlaydate
|
||||
|
||||
extension Sprite {
|
||||
/// Information about a sprite intersected by a line segment,
|
||||
/// mirroring `SpriteQueryInfo`.
|
||||
/// A sprite intersected by a line segment. Wraps `SpriteQueryInfo`.
|
||||
public struct QueryInfo {
|
||||
public let sprite: Sprite
|
||||
/// How far along the segment (0...1) the segment enters the sprite.
|
||||
/// Entry point's position along the segment, 0...1.
|
||||
public let ti1: Float
|
||||
/// How far along the segment (0...1) the segment exits the sprite.
|
||||
/// Exit point's position along the segment, 0...1.
|
||||
public let ti2: Float
|
||||
public let entryPoint: (x: Float, y: Float)
|
||||
public let exitPoint: (x: Float, y: Float)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// A floating-point rectangle mirroring `PDRect`.
|
||||
/// A floating-point rectangle, in pixels. Wraps `PDRect`.
|
||||
public struct Rect: Sendable {
|
||||
/// Left edge.
|
||||
public var x: Float
|
||||
/// Top edge.
|
||||
public var y: Float
|
||||
public var width: Float
|
||||
public var height: Float
|
||||
|
||||
/// Creates a rect from an origin and size.
|
||||
public init(x: Float, y: Float, width: Float, height: Float) {
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
Reference in New Issue
Block a user