-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
67 lines (55 loc) · 1.41 KB
/
Copy pathtypes.ts
File metadata and controls
67 lines (55 loc) · 1.41 KB
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
58
59
60
61
62
63
64
65
66
67
import { type IPlainVec2D, Vec2D } from '../../common/math/geom2d.ts'
import { type UnitRatio, type float64, type uint32 } from '../../common/types/numbers.ts'
import { type Action } from '../../common/types/typecons.ts'
export type PaddleDirection = -1 | 0 | 1
export type GamePhase =
'unstarted' |
'running' |
'paused' |
'completed' |
'game-over'
export type GameBrickPower = 1 | 2 | 3
export interface IBallState {
ballSource: IPlainVec2D
ballTarget: IBreakoutIntersection
ballPosition: UnitRatio
}
export interface IBrickState {
x: uint32
y: uint32
power: GameBrickPower
}
export interface IBreakoutIntersectionB {
x: uint32
y: uint32
power: GameBrickPower
}
export interface IBreakoutIntersection {
newCenter: IPlainVec2D
reflectedDirection: IPlainVec2D
brick?: IBrickState
isLastHit?: boolean
isStageBottom?: boolean
}
export interface IBreakoutTrajectory {
head: IPlainVec2D
tail: IBreakoutIntersection[]
}
export interface IInternalGameState extends IBallState {
paddleCenter: float64
score: uint32
bricks: IBrickState[]
frameDuration: float64
trajectory: IBreakoutTrajectory
}
export interface IControllableGameState {
phase: GamePhase
paddleDirection: PaddleDirection
virtualControls: boolean
debug: boolean
}
export interface IComputedGameState {
ballCenter: Vec2D
ballDirection: Vec2D
}
export type UpdateGameState = Action<Partial<IControllableGameState>>