forked from zero-to-mastery/ZTM-Quest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcake.interaction.js
More file actions
38 lines (35 loc) · 926 Bytes
/
Copy pathcake.interaction.js
File metadata and controls
38 lines (35 loc) · 926 Bytes
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
import { speedByScaleFactor } from '../../constants';
import { displayDialogue } from '../../utils';
const cakeDialogue = [
`
<div>
<h2>You ate the whole cake!</h2>
<p>
You feel an overwhelming sugar rush!
</p>
<p>
Your heart is racing and you're full of energy!
</p>
</div>
`,
];
export const interactionWithCake = (player, k, map) => {
player.onCollide('cake', () => {
player.state.speed = speedByScaleFactor * 2.5;
displayDialogue({
k,
player,
text: cakeDialogue,
});
});
player.onCollideEnd('cake', () => {
setTimeout(() => {
player.state.speed = speedByScaleFactor; // Reset to default speed
displayDialogue({
k,
player,
text: ['SUGAR CRASH'],
});
}, 10000);
});
};