-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
44 lines (42 loc) · 1.19 KB
/
store.js
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
export let Store = {
speed: {
gravity: 1,
jump: 20,
},
player: {
yPosition: 300,
xPosition: 0,
speed: 1,
heightOf: {
jump: 180,
currentPosition: 0,
},
do: {
right: () => {
// while (store.player.controller.actions.isPressRight) {
store.player.xPosition += 7;
// }
},
left: () => {
store.player.xPosition = store.player.xPosition - 7;
// player.style.left = `${store.player.xPosition}px`;
},
jump: () => {
store.speed.jump = 1;
let speed = store.speed.jump;
let jumpfunc = setInterval(() => {
store.player.yPosition += 11;
speed += 11;
if (speed >= store.player.heightOf.jump) clearInterval(jumpfunc);
}, 10)
},
},
controller: {
actions: {
left: false,
right: false,
space: false,
}
}
},
}