-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
51 lines (40 loc) · 1.19 KB
/
sketch.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const GRID_SIZE = 20;
let pacMan, blinky, pinky, inky, clyde;
let pellets;
function setup() {
const canvasWidth = 28 * GRID_SIZE;
const canvasHeigth = 31 * GRID_SIZE;
frameRate(30);
createCanvas(canvasWidth, canvasHeigth + 50);
pellets = initPellets();
pacMan = new PacMan(MAP_MATRIX, GRID_SIZE, pellets);
blinky = new Ghost(MAP_MATRIX, GRID_SIZE);
pinky = new Ghost(MAP_MATRIX, GRID_SIZE);
inky = new Ghost(MAP_MATRIX, GRID_SIZE);
clyde = new Ghost(MAP_MATRIX, GRID_SIZE);
textSize(30);
fill(0, 102, 153);
text('SCORE', 20, canvasHeigth + 10)
}
function draw() {
background(0);
textSize(15);
fill(255,255,20);
stroke(20,20,200);
strokeWeight(1);
textAlign(LEFT);
text('SCORE :', 20, 31 * GRID_SIZE + 10);
textAlign(RIGHT);
text((pellets.length - pacMan.pellets.length) * 10, 100, 31 * GRID_SIZE + 10, 40);
drawMap(GRID_SIZE);
pacMan.update(frameCount);
blinky.update(frameCount, pacMan);
pinky.update(frameCount, pacMan);
inky.update(frameCount, pacMan, blinky);
clyde.update(frameCount, pacMan);
pacMan.draw();
blinky.draw();
pinky.draw();
inky.draw();
clyde.draw();
}