Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Major Assignment: Pacman Game Major Assignment: Pacman Game 1 Major Assignment: Pacman Game 300580 Programming Fundamentals Week 10 Assignment The major assignment involves producing a Pacman style...

1 answer below »
Major Assignment:
Pacman Game

Major Assignment: Pacman Game 1



Major Assignment:
Pacman Game
300580
Programming Fundamentals
Week 10

Assignment
The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.
The essence of the game – is to make Clara eat all available leaves, while avoiding collisions with ghosts chasing her. Clara is to
e controlled by a player through keyboard. Apart from leaves, there are also mushrooms available in Clara’s world, but unlike
the practicals, Clara is unable to push them around, but instead she can eat those mushrooms and gain superpowers (for a short
period of time she will be able to eat ghosts). Ghosts always start at their home base (also known as Ghost Healer) that is always
marked by a think red dot. Somewhere close to a Ghost Healer there is always a ghost wall (represented by a square su
ounded
y dotted red line). The ghost wall can be penetrated by ghosts, but not by Clara, making the ghost base protected from invasion.
When Clara eats a mushroom, ghosts change their colour and would start running away from Clara. This mode when Clara is
able to eat ghosts is called “scared” mode. In the “scared” mode ghosts run away from Clara rather than chasing her and if a
collision between a ghost and Clara occurs while in this mode – the ghost would change into an almost invisible creature that
moves from the collision location to the base and then resu
ects once the base is reached. If a collision happens between Clara
and a ghost in any other mode – then Clara looses and the game is over.
In solving the major assignment you will not be entirely on your own, as the steps involved are
oken up in this assignment
ief. During practical classes your tutors will explain you the basics in completing these steps. Before we start, there will be an
explanation of all commands available in both Clara and the Ghosts vocabularies.

Major Assignment: Pacman Game 2

Important Requirements
For your convenience, all important requirements specified in this
ief are re-listed here:
- Clara and the Ghosts must be able to move from one side of the game to the other with the “wrapAroundWorld()”
method
- Clara must be capable of being controlled with at least the a
ow keys on the keyboard
- Clara must not move in the game until after an a
ow key pressed
- Clara must stop before hitting trees or the ghost wall
- Clara must be able to eat leaves, and play the appropriate sound when doing so
- When all the leaves are eaten, the game must progress to the next level
- When each level starts the intro sound must be played once for each level and Clara and the Ghosts must not be able to
move until after the intro sound has completed playing
- Ghosts must move slower than Clara when moving normally and when scared
- Ghosts must stop before hitting trees
- Ghosts must randomly decide on a direction to go in when they find themselves in an intersection
- When Clara and a Ghost collide, and the Ghost is neither dead nor scared, she must die, and play the appropriate sound
- When Clara is dead the player must not be able to continue controlling her
- Clara must be able to eat mushrooms, and this must make the Ghosts scared
- When the Ghosts are scared, they must run the appropriate animation
- When Clara and a Ghost collide, and the Ghost is scared, the Ghost must die, play the appropriate sound and play the
appropriate animation
- When Ghosts are dead they must attempt to return to the Ghost Healer
- When Ghosts collide with the Ghost Healer they must no longer be dead
- You must make, at a minimum, one extra level
- All files must compile and the game must run.
Important note 1
While in the past you only had to work with MyClara.java, this time you will also have to edit Ghost.java for all the logic related
to the Ghosts as well as MyClara.java for all the Clara functionality.
Important note 2
Do not let the following list of commands scare you, as they are further explained in the assignment
ief and your tutors will
help you to select those commands that you need for each task.
Major Assignment: Pacman Game 3

Important note 3
For this assignment you should no longer have a main loop (for or while) inside act(). Instead you should rely on Greenfoot
executing act() repetitively (similar to how you did in Practical 2). The stop(); command MUST NOT be used in this assignment.
Clara’s vocabulary
For this assignment, the following commands are available for Clara right from the start:
Command Name Command Description Command Input Command Output
treeFront() Checks if there is a tree in
front of Clara.
Nothing. true if there is a tree in
front of Clara.
false if there is not a tree in
front of Clara.
ghostWallFront() Checks if there is a ghost
wall in front of Clara.
Nothing. true if there is a ghost wall
in front of Clara.
false if there is not a ghost
wall in front of Clara.
getDirection() Gets which direction Clara
is facing.
Nothing. A string which represents
the direction Clara is
facing.
“up” if Clara is facing up
toward the top of the
screen.
“down” if Clara is facing
toward the bottom of the
screen.
“right” if Clara is facing to
the right side of the screen.
“left” if Clara is facing to
the left side of the screen.
setDirection(string) Makes Clara face a
specific direction.
It will not change her
direction if there is a tree
in the way.
A String, which specifies
which direction you want
Clara to face.
“up” - face toward the top
of the screen.

“down” - face toward the
ottom of the screen.

“right” - face toward the
ight side of the screen.

“left” - face toward the left
side of the screen.
Nothing.
Major Assignment: Pacman Game 4

Clara’s vocabulary - continued
Command Name Command Description Command Input Command Output
move(int)
Moves Clara at the
specified speed.
An integer, which specifies
how fast you want Clara
to move.
Nothing.
makeScared() Clara lets the Ghosts know
that she is ready to eat,
and makes them scared.
For more information, see
the “isScared() function in
the Ghost’s vocabulary.
Also see the section “Part
10 – Eating Mushrooms
and Making Ghosts
Eatable”
Nothing. Nothing.
isScared() Clara checks whether the
Ghosts are still scared of
her.
Nothing. true if the Ghosts are still
scared of her.
false if the Ghosts are no
longer scared of her.
animate() Clara continues her
animation by one frame.
For more information, see
the section “Part 2 -
Animating Clara’s
Movement”.
Nothing. Nothing.
animateDead() Clara visually shows that
she is dead.
For more information, see
the section “Part 9 -
Ghosts Colliding With
Clara and Losing”
Nothing. Nothing.
onLeaf() Checks if Clara is on top
of a leaf.
Nothing. true if Clara is on top of a
leaf.
false if Clara is not on top
of a leaf.
emoveLeaf() Clara removes a leaf that
she is standing on.
Nothing. Nothing.
Will show an e
or if she
tries to remove a leaf that
isn’t there.
Major Assignment: Pacman Game 5

Clara’s vocabulary - continued
Command Name Command Description Command Input Command Output
onMushroom() Checks if Clara is on top of
a mushroom.
Nothing. true if Clara is on top of a
mushroom.
false if Clara is not on top of a
mushroom.
emoveMushroom() Clara removes a mushroom
that she is standing on.
Nothing. Nothing.
Will show an e
or if she tries
to remove a mushroom that
isn’t there.
allLeavesEaten() Checks if Clara has eaten
all of the leaves in the level.
Nothing. true if there are no more leaves
for Clara to eat.
false if there are still leaves for
Clara to eat.
isClaraDead() Checks if Clara should be
dead.
For more information, see
the function
“makeClaraDead()” in the
Ghost’s vocabulary and the
section “Part 9 – Ghosts
Colliding with Clara and
Losing”
Nothing.
true if Clara should be dead.
false if Clara should not be
dead.
playClaraDieSound() Plays Clara’s death sound.
For more information see
the section “Part 9 – Ghosts
Colliding with Clara and
Losing”
Nothing Nothing
isClaraDieSoundStillPlaying() Checks if Clara’s death
sound is still playing.
For more information see
the section “Part 9 – Ghosts
Colliding with Clara and
Losing”
Nothing. Nothing.
playLeafEatenSound() Plays the sound of Clara
eating a single leaf.
Nothing. Nothing.
playPacmanIntro() Plays the pacman intro
sound.
Nothing. Nothing.
Major Assignment: Pacman Game 6

Clara’s vocabulary - continued
Command Name Command Description Command Input Command Output
isPacmanIntroStillPlaying() Checks if the pacman intro
sound is still playing.
For more information see
the section “Part 4 – Eating
Leaves and Winning”
Nothing. Nothing.
wrapAroundWorld() Enables Clara to
automatically move off one
side of the game, and end
up on the other.
Nothing. Nothing.
getCu
entLevelNumber() Gets the number of the
cu
ent level.
Nothing. An integer representing the
cu
ent level number.
E.g. If the cu
ent level is 1,
then it will return 1.
advanceToLevel(char[][]) Changes the cu
ent game
level to the one specified. If
it is sent null, then it will
automatically load the first
level.
To see more information on
how to use it, see “Part 4 –
Eating Leaves and
Winning”
For more information on
making levels to send the
method, see “Part
Answered 685 days After Jun 08, 2021

Solution

Robert answered on Apr 25 2023
43 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here