Question: hello i made this code with processing that shows a pacman eating circles and I am hoping if you can help me modify this code
hello i made this code with processing that shows a pacman eating circles and I am hoping if you can help me modify this code by having two ghosts chasing the pac man left and right. I would also be happy if you were able to make the pac man chomp. The code is shown below:
int pacX, pacY; Position of PacMan
int pacSize ; Size of PacMan
int dotSize ; Size of dots
int dotSpacing ; Spacing between dots
int numDots ; Number of dots
int score ; Score
void setup
size;
pacX width ;
pacY height ;
void draw
background;
Draw dots
for int i ; i numDots; i
int dotX i dotSpacing dotSpacing ;
int dotY height ;
fill;
ellipsedotX dotY, dotSize, dotSize;
Draw PacMan
fill;
arcpacX pacY, pacSize, pacSize, PI ; Chomping animation
Move PacMan
pacX pacX width; PacMan moves to the right
delay; Slow down animation
void checkCollision
for int i ; i numDots; i
int dotX i dotSpacing dotSpacing ;
int dotY height ;
float distance distpacX pacY, dotX, dotY;
if distance pacSize dotSize
score;
Remove dot from the screen
Optional: You can also play a sound effect
void keyPressed
if keyCode UP
pacY ; Shift PacMan up
else if keyCode DOWN
pacY ; Shift PacMan down
else if keyCode LEFT
pacX ; Shift PacMan left
else if keyCode RIGHT
pacX ; Shift PacMan right
void displayScore
fill;
textSize;
textScore: score, ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
