-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjump.ts
79 lines (70 loc) · 2.17 KB
/
jump.ts
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
import { IPerson, Person } from "./class"
import { Movable } from "./move";
export class Jump {
positionBody:IPerson
private movable: Movable;
constructor(movable: Movable,Position:IPerson) {
this.positionBody = Position
this.movable = movable;
}
jump(rotate:string | null) {
console.log(this.positionBody.stateDoubleJump)
if (this.positionBody.stateDoubleJump < 2) {
let positionY = -10
let size = -1.5
let startPosition = this.positionBody.positionBody.y
let startSide=this.positionBody.side
const startJump = setInterval(() => {
if (rotate === "left") {
this.movable.moveBack()
}
if (rotate === "right") {
this.movable.moveForward()
}
this.movejumpUp(positionY)
this.changeJump(startSide,positionY)
this.sizeJump(size)
if (this.positionBody.stateDoubleJump === 2) {
startPosition = this.positionBody.positionBody.y
positionY = -10
size = -1.5
this.positionBody.stateDoubleJump++
}
if (startPosition - 100 > this.positionBody.positionBody.y) {
positionY = +10
size = +1.5
}
if (this.positionBody.positionBody.y === 300) {
console.log("null")
this.positionBody.stateDoubleJump = 0
clearInterval(startJump)
return "aaa"
}
}, 50)
if (this.positionBody.stateDoubleJump === 1) {
clearInterval(startJump)
}
this.positionBody.stateDoubleJump++
}
}
private changeJump(startSide:string,positionY:number){
if (startSide == "right") {
this.positionBody.positionLegRight.sizeY += positionY * 0.1
} else {
this.positionBody.positionLegLeft.sizeY += positionY * 0.1
}
}
private sizeJump(size:number){
this.positionBody.positionBody.sizeY += size
this.positionBody.positionLegLeft.sizeY += size
this.positionBody.positionLegRight.sizeY += size
}
private movejumpUp(positionY:number){
this.positionBody.positionBody.y += positionY
this.positionBody.positionHead.y += positionY
this.positionBody.positionLegLeft.y += positionY * 1.25
this.positionBody.positionLegRight.y += positionY * 1.25
this.positionBody.positionHandRight.y += positionY * 1.1
this.positionBody.positionHandLeft.y += positionY * 1.1
}
}