MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / loop

Function loop

assets/js/Motorcycle.js:72–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70var playing = true;
71var k = { ArrowUp: 0, ArrowDown: 0, ArrowLeft: 0, ArrowRight: 0 };
72function loop() {
73 speed -= (speed - (k.ArrowUp - k.ArrowDown)) * 0.05;
74 t += 5 * speed;
75 ctx.fillStyle = "#19f";
76 ctx.fillRect(0, 0, c.width, c.height);
77
78 ctx.fillStyle = "black";
79 ctx.beginPath();
80 ctx.moveTo(0, c.height);
81 for (let i = 5; i < c.width; i++)
82 ctx.lineTo(i, c.height - noise(t + i) * 0.25);
83
84 ctx.lineTo(c.width, c.height);
85 ctx.fill();
86
87 player.draw();
88 requestAnimationFrame(loop);
89}
90onkeydown = d => k[d.key] = 1;
91onkeyup = d => k[d.key] = 0;
92loop();

Callers 1

Motorcycle.jsFile · 0.70

Calls 2

noiseFunction · 0.85
drawMethod · 0.45

Tested by

no test coverage detected