html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<canvas width="600" height="400" id="canv">
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
canvas {
border: 2px solid black;
background-image: url('https://media.istockphoto.com/id/1221860198/photo/arrows-marks-on-the-asphalt-on-an-empty-parking-lot.jpg?s=170667a&w=0&k=20&c=fvrwmaa_sY0sPd49LhCDYyDL65QJwUEvCYGcHWuOFKo=');
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
Enter to Rename, Shift+Enter to Preview
js
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
//setup
let canv = document.getElementById("canv");
let context = canv.getContext("2d");
var dir = 0;
var time = Date.now();
var speed = 300;
var player = {
x: 280,
y: 180
}
//brick class
function brick(x, y) {
this.x = x;
this.y = y;
this.cold = function() {
if (
player.x + 40 > x &&
player.x < x + 40 &&
player.y + 50 > y &&
player.y < y + 40
)
{
return true;
}
else {
return false;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run