xxxxxxxxxx
72
let x=10;
pacmanX=145;
pacmanY=400;
let edge= 600;
let dotXs = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650]
let isEaten = [false, false, false, false, false, false, false, false, false, false, false, false, false ]
let food;
function setup() {
createCanvas(700, 600);
}
function draw() {
background(0,0,205);
pacman();
food();
eat();
if(keyIsPressed){
if(keyCode== RIGHT_ARROW){
pacmanX +=1;
}
else if(keyCode==LEFT_ARROW){
pacmanX -=1;
}
}
if(keyIsPressed){
if(keyCode==UP_ARROW){
pacmanY-=10;
}
else if(keyCode==DOWN_ARROW){
pacmanY+=10;
}
}
print('Y= ' + pacmanY)
print('X= ' + pacmanX)
if (pacmanY == 100) {
for(let idot=0; idot < dotXs.length; idot++){
if (pacmanX == dotXs[idot]) {
isEaten[idot] = true;
}
}
}
function food(){
for(let idot=0; idot < dotXs.length; idot++){
stroke(255,215,0)
strokeWeight(10);
if (!isEaten[idot])
point(dotXs[idot],100);
}
}
function pacman(){
fill(255,215,0);
arc(pacmanX,pacmanY,100,100,0.50,5.49);
}
}
function eat(){ // food to disappear when Pac-Man on food
}