Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
OutRed
GitHub Repository: OutRed/Cuphead-webgame
Path: blob/main/js/characters/cuphead.js
140 views
1
var animSet = [];
2
3
animSet["idle"] = [
4
"img/sprites/cuphead/Idle/cuphead_idle_",
5
5,
6
function()
7
{
8
if(cuphead.frame > cuphead.maxFrame)
9
cuphead.frame = 1;
10
11
cuphead.chosenPath = cuphead.path + stdizeCount(cuphead.frame) + '.png';
12
makeImage(
13
cuphead.chosenPath,
14
cuphead.x, cuphead.y,
15
cuphead.width, cuphead.height,
16
cuphead.flip
17
);
18
19
if(cuphead.currentPick < cuphead.speedTick)
20
{
21
cuphead.currentPick += deltaTime;
22
return;
23
}
24
else
25
cuphead.currentPick = 0;
26
27
if(!goaledEnd)
28
{
29
if(cuphead.frame > cuphead.maxFrame - 1)
30
goaledEnd = true;
31
else
32
cuphead.frame++;
33
}
34
else
35
{
36
if(cuphead.frame < 2)
37
{
38
goaledEnd = false;
39
isPausePassed = false;
40
}
41
else
42
cuphead.frame--;
43
}
44
}
45
];
46
animSet["run"] = [
47
"img/sprites/cuphead/Run/Normal/cuphead_run_",
48
16,
49
false
50
];
51
animSet["jump"] = [
52
"img/sprites/cuphead/Jump/Cuphead/cuphead_jump_",
53
8,
54
false
55
];
56
57
//Creating Cuphead character and getting his sprites
58
var cuphead = new Character(
59
animSet,
60
x=150,y=150,
61
width=100,height=150,
62
speed=6
63
);
64
65
cuphead.chosenAct = "run";
66
67
cuphead.speedTick = 40;
68
69
var goaledEnd = false;
70
var gravity = 5;
71
72
cuphead.veloY = 0;
73
74
var givenForce = 10;
75
76
prepareVelocity(cuphead);
77
78
cuphead.update = function() {
79
//Collecting time to make seeking vector to zero
80
this.velocity.collectedTime += 0.15;
81
82
//Simulate physics
83
simPhysics(this);
84
85
if(this.isGround == false) {
86
this.chosenAct = "jump";
87
}
88
89
//In result, those ops just comfirm char's positions by his velocities
90
resultPhysics(this);
91
}
92
93