-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (34 loc) · 1007 Bytes
/
Copy pathscript.js
File metadata and controls
45 lines (34 loc) · 1007 Bytes
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
const CELL_SIZE = 30;
const FIELD_SIZE = 30;
var canvas = document.querySelector("#canvas");
var context = canvas.getContext("2d");
canvas.width = 1000;
canvas.height = 500;
const mouse = getMouse(canvas);
drawGrid();
const game = new Game();
function clearCanvas() {
canvas.width |= 0;
}
function drawGrid() {
context.strokeStyle = "blue";
context.lineWidth = 0.5;
for (let i = 0; i < canvas.width / CELL_SIZE; i++) {
context.beginPath();
context.moveTo(i * CELL_SIZE, 0);
context.lineTo(i * CELL_SIZE, canvas.height);
context.stroke();
}
for (let i = 0; i < canvas.height / CELL_SIZE; i++) {
context.beginPath();
context.moveTo(0, i * CELL_SIZE);
context.lineTo(canvas.width, i * CELL_SIZE);
context.stroke();
}
context.lineWidth = 2;
context.strokeStyle = "red";
context.beginPath();
context.moveTo(0, 75);
context.lineTo(canvas.width, 75);
context.stroke();
}