Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
OutRed
GitHub Repository: OutRed/Cuphead-webgame
Path: blob/main/js/main.js
139 views
1
/*Plans:
2
*
3
* WE SHOULD:
4
*
5
* - Initialization system to load in advance to avoid an white space
6
*
7
* - Divide some abilities of character to "components" as Unity and Unread do
8
*
9
*/
10
11
class Square {
12
constructor(x,y,
13
width,height
14
) {
15
this.x = x;
16
this.y = y;
17
this.width = width;
18
this.height = height;
19
}
20
21
draw()
22
{
23
ctx.beginPath();
24
ctx.rect(this.x,this.y,this.width,this.height);
25
ctx.fill();
26
ctx.closePath();
27
}
28
}
29
var testSq = new Square(0,400,500,200);
30
31
//Main function of the script
32
function main()
33
{
34
ctx.clearRect(0,0,canvas.width,canvas.height);
35
36
testSq.draw();
37
38
cuphead.update();
39
cuphead.animate();
40
}
41
42
43
//THE MOST IMPORTANT FUNCTION WHAT WE HAVE!!!
44
/*!!!*/ setInterval(main, 1); /*!!!*/
45
//THE MOST IMPORTANT FUNCTION WHAT WE HAVE!!!
46
47