-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplan.txt
168 lines (127 loc) · 4.42 KB
/
plan.txt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
TODO:
How to generate cave shape and render
start with simple pink noise for shape
generate in javascript, write height values for top and bottom to 1d texture
shadow and cave edge/lip can be generated using those height vals as a distance func
main texture of cave comes from noise: infrequent large stalagmite things get colored
brightly beyond some height threshold; high frequency noise colore darkly when
dropping beneath the surface by some threshold.
Function (of x coord) that randomly distributes 'path points'
Algo here can change:
purely random
sinusoidal
square wave
Long slopes up and long slopes down
Function (of x coord) that returns a pair of path points: the one prior and after the current x pos
Base path is uses those two points to get an actual line
Cave 'carver' whose height is deterined by diffulty algo moves along path
That 'carving' provides base heights for cave top/bottom, to which we add pink noise
The above will be a continuous function of x, which we sample when forming the 1d tex
How does the camera work (it's also kinematic, but has a follow target)
Force vector on camera is proportional to diff between camera pos and player body center
That force is capped at some maximum
Additionally, the initial force calculation must take into account other forces acting on
cam, so that the net force is proportional to diff
There is a 'backward' force on the camera that behaves like friction: if stops accelerating
forward it will come to a stop.
The camera's size/pos are used to convert from world to screen coords (part of the glsl state build)
How difficulty evolves in time
How does game reset work
Collision between player/coin and player/cave
Player kinematics
StateTransformer
setUp()
tearDown()
handleEvent()
update()
render()
Simulation extends StateTransformer
setUp() {}
tearDown() {}
update(deltaTime) {
While(!EventQueue.empty())
handleEvent(EventQueue.next())
subStateTransformer.update(deltaTime)
}
handleEvent(event) {
// Handle 'transformer change' events by swapping the StateTransformer and calling setup/teardown
subStateTransformer.handleEvent(event)
}
render() {
subStateTransformer.render()
}
GameStateTransformer extends StateTransformer
setUp() {
this.state = {
player: {position, velocity, mass, activeForces, dying, dead},
coins: [{position, dying, dead}],
cave: {},
camera: {position, width, height, activeForces}
score,
}
this.uniforms = {};
// Set up left/right/up key listeners which
// emitt events like 'BOOST', "BRAKE", "ACCEL_UP"
}
update(deltaTime) {
// update player accel/vol/position
// update cave geometry
// generate coins routine
// general cleanup routine
updateKinematics()
findCollisions().forEach(col => EventQueue.push(collision event))
updateGLSLUniforms(this.state);
}
handleEvent(event) {
// collision events, deathStart, deathFinish, boost, break,
}
updateKinematics() {
const entities = [camera, player];
entities.forEach(entity => {
// sum forces
// use f = ma to determine acceleration
// update velocity and position based on acceleration
});
}
updateGLSLUniforms(state) {
}
render {
}
CaveGenerator {
constructor() {
this.junctures = []; //(x,y) points each time path slope changes
}
getTopSurfaceY(x) {
const noise = blah(x);
return getBasicTopSurfaceY(x) + noise;
}
getBottomSurfaceY(x) {
const noise = blah(x);
return getBasicBottomSurfaceY(x) - noise;
}
getBasicTopSurfaceY(x) {
const initialY = getPathY(x) + getApertureHeight(x);
const overhang = max(initialY - maxY, 0);
return initialY - overhang;
}
getBasicBottomSurfaceY(x) {
return getBasicTopSurfaceY(x) - getApertureHeight(x);
}
getApertureHeight(x) {
could event just be linear if we wanted to be simple
}
// These might also need to be functions of x like getApertureHeight(x)
// minFlatLength, maxFlatLength, minSlantLength, maxSlantLength, minSlope, maxSlope
getPathY(x) {
Find `nextJuncture` via:
Add up previous section lengths to see if x is in unexplored territory
If so, generate a new juncture point
Every other section is flat/slant, so base on index
xPos is based on min/maxLength params
yPos is based on a random slope via min/maxSlope params (and a global min/max Y)
If not grab pre-generated juncture point
Find the path height via linear interpolation from `previousJuncture` to `nextJuncture`
}
getSectionLength(x) {
}
}