Question: Hello, I tried to execute this code on processing but it does not work. Can I please get help for the game to run correctly?
Hello, I tried to execute this code on processing but it does not work. Can I please get help for the game to run correctly? you can modify the game however you like just as long as its working
CODE FOR MY GAME:
PShape ghost ghost eyes eyes;
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
int ghostX ghostY; Position of Ghost
int ghostX ghostY; Position of Ghost
int ghostSpeed ; Ghosts' movement speed
boolean mouthOpen true; Controls PacMan's chomping animation
void setup
size;
pacX width ;
pacY height ;
Initialize ghost positions
ghostX width ;
ghostY height ;
ghostX width ;
ghostY height ;
Load ghost and eyes models
ghost loadShapeghostsvg;
eyes loadShapeeyessvg;
ghost loadShapeghostsvg;
eyes loadShapeeyessvg;
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 Ghosts
drawGhostghost eyes ghostX ghostY;
drawGhostghost eyes ghostX ghostY;
Draw PacMan with chomping animation
fill;
arcpacX pacY, pacSize, pacSize, mouthOpen : PI mouthOpen TWOPI : PI ;
Chomping animation
if frameCount
mouthOpen mouthOpen;
Move PacMan
pacX pacX width;
Move Ghosts towards PacMan
moveGhostTowardsPacmanghostX ghostY;
moveGhostTowardsPacmanghostX ghostY;
Check for collisions
checkCollision;
Show score
displayScore;
void drawGhostPShape ghost, PShape eyes, int x int y
Draw default ghost with reducedsize eyes on top
ghost.enableStyle;
shapeghost x y;
shapeeyes x y ;
Disable style of ghost and draw same ghost and eyes
ghost.disableStyle;
shapeghost x y;
shapeeyes x y ;
Change fill to red and draw same ghost and eyes
fill;
shapeghost x y;
shapeeyes x y ;
noFill;
void moveGhostTowardsPacmanint ghostX, int ghostY
if ghostX pacX
ghostX ghostSpeed;
else
ghostX ghostSpeed;
void checkCollision
Check collisions with PacMan
void displayScore
fill;
textSize;
textScore: score, ;
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
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
