Question: Write a JAVA program that plays a Pac-man game. The game plays on a 10 by 10 grid. Pac-man is depicted as # and others
Write a JAVA program that plays a Pac-man game. The game plays on a 10 by 10 grid. Pac-man is depicted as # and others as *. All characters should remain within the grid. The pac-mans are defined as classes, and the objects are stored in an array. The pac-man class has a move() method, which randomly moves one square in any direction but not diagonally. The movement should be within the grid. The move() method will be called at a time intervals (e.g., 0.5 second). The pac-man starts to move from the top-left corner. The game ends if a pac-man reaches the bottom-right corner or if it repeats more than a certain times (e.g., 1000).
Improve the above assignment by doing the following:
Includes new features such as a maze, eating pac-dots, and two objects of pac-mans (a single pacman and 3 ghosts). A maze is defined by using a 2D-array. You can pre-define the maze. In the same way, pac-dots also can be defined by using a 2D-array.
You may want to have one more class, which is PacmanGame. The PacmanGame class includes data members (a map, an array of pac-man objects) and methods (main(..), frame(..), and so on). A pacman starts from the top-left corner of the map, while ghosts do from the middle. Only pacman can eat pac-dots, but ghosts cannot. When the pacman reaches the bottom-right corner of the map, the frame(...) method return true. Then the game is over (or if it repeats more than a certain times (e.g., FRAMES)).
You do not need to check collision between the pacman and ghosts in HW3 (we will do later). The movement is still randomly determined for both the pacman and ghosts.
Pac-man is depicted as [P], a ghost as [G], and pac-dots as *. After eating pac-dots, please leave blanks.
You do not need to ask how many pac-man plays. Note that there are a single pacman and 3 ghosts. You have to use arrays and method overriding.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
