xxxxxxxxxx
52
// Adds four more spots being checked by Pac-Man to detect a wall ahead
// See move.js tab for the code
// Tori:
// 1) Show them how to make a new .js file
// 2) Briefly explain the code on that page (Do NOT have them write the code themselves)
// Students:
// 1) After being taught what the code does
// 2) Copy the code on the move.js file here
// 3) Paste it in your sketch on a new move.js file
// 4) Erase your old movePacMan() function
// 5) Save your sketch
let img;
let x = 170;
let y = 30;
let personalSpace = 21;
let diam = 24;
function preload() {
img = loadImage("maze.png");
}
function setup() {
createCanvas(500, 500);
}
// ------------------ //
// DRAW LOOP //
// ------------------ //
function draw() {
image(img, 0, 0);
movePacMan();
drawPacMan();
}
// -------------------- //
// DRAW PACMAN //
// -------------------- //
function drawPacMan() {
noStroke();
fill(255, 255, 0);
ellipse(x, y, diam, diam);
}