-
Notifications
You must be signed in to change notification settings - Fork 1
/
PhysicsConstants.swift
57 lines (51 loc) · 2.34 KB
/
PhysicsConstants.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// PhysicsConstants.swift
// star-dash
//
// Created by Lau Rui han on 12/3/24.
//
import Foundation
struct PhysicsConstants {
struct CollisionCategory {
static let none: UInt32 = 0
static let max: UInt32 = 0xFFFFFFFF
static let player: UInt32 = 0b1 << 0
static let monster: UInt32 = 0b1 << 1
static let collectible: UInt32 = 0b1 << 2
static let obstacle: UInt32 = 0b1 << 3
static let tool: UInt32 = 0b1 << 4
static let wall: UInt32 = 0b1 << 5
static let floor: UInt32 = 0b1 << 6
}
struct CollisionMask {
static let player = CollisionCategory.max ^ CollisionCategory.player ^ CollisionCategory.collectible
static let monster = CollisionCategory.player | CollisionCategory.tool
static let collectible = CollisionCategory.none
static let obstacle = CollisionCategory.player | CollisionCategory.monster | CollisionMask.tool
static let tool = CollisionCategory.max ^ CollisionCategory.collectible ^ CollisionCategory.tool
static let wall = CollisionCategory.player | CollisionCategory.monster | CollisionCategory.tool
static let floor = CollisionCategory.player | CollisionCategory.monster | CollisionCategory.tool
}
struct ContactMask {
static let player = CollisionCategory.floor | CollisionCategory.collectible
static let monster = CollisionCategory.player
static let collectible = CollisionCategory.player
static let obstacle = CollisionCategory.none
static let tool = CollisionCategory.obstacle
static let wall = CollisionCategory.tool | CollisionCategory.player
static let floor = CollisionCategory.player
}
struct Dimensions {
// TODO: determine appropriate size for each
static let player = CGSize(width: 70, height: 110)
static let monster = CGSize(width: 100, height: 140)
static let collectible = CGSize(width: 60, height: 60)
static let obstacle = CGSize(width: 60, height: 60)
static let tool = CGSize(width: 60, height: 60)
static let wall = CGSize(width: 60, height: 60)
static let floor = CGSize(width: 300, height: 60)
}
static let jumpImpulse = CGVector(dx: 15, dy: 250)
static let runVelocity = CGVector(dx: 60, dy: 0)
static let maxRunVelocity = CGVector(dx: 250, dy: 0)
}