Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started