Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The object of this game is to avoid being touched by the robots, and in the process get out of the room via the door
The object of this game is to avoid being touched by the robots, and in the process get out of the room via the door D Try to get out of as many rooms levels and crash as many robots as possible.
How to play: The user clicks the start button and the game board appears. The user is at level one and hisher score is zero shown in the status window There will be afence the Xs around the x area. Robots are indicated by an R and a Human by H Both the Human and four Robots are placed randomly
The player can move the Human in four directions Up Down, Left, and Right to avoid the oncoming Robots. The player scores points in ways. Get out of the room via the door, thus ending the level. You get currentLevel points Get the robots to collide. No easy task. When robots collide they both die and you get a point for each. Dead robots can't move and are displayed as an asterisk
Initially, the robots can only move of the time and can when able move in eight directions and in each successive level there appears one additional robot and all robots can move more often ie for level there will be five robots with move ability You will use Math.random to determine if a robot can move.
What to do: You will create an application Robots.java
boardArea.setFontnew FontCourier New",Font.PLAIN,;
You will use Strings for output of the game board, results, and score.
Your solution will use the following instance variables.
private final char HUMAN H;
private final char ROBOT R;
private final char JUNK ;
private final int doorX ; location of door
private final int doorY ;
private final int numRows ; dimensions for playing area
private final int numCols ;
private JPanel panel; to put the buttons in
private JButton buttonUp;
private JButton buttonDown;
private JButton buttonLeft;
private JButton buttonRight;
private JButton buttonStart;
private JTextArea boardArea;where the game is played
private JTextArea resultsArea; results reported here
private JScrollPane resultsScroller;
private JTextField currentScoreField; score reported here
private String boardString ; holds contents of playing
area
private String resultsString ;
private String scoreString ;
private int level;
private int score;
private int zombieCount;
private int zombieKilled;
private int humanX;
private int humanY;
private boolean alive;
private boolean nextLevel;
private double moveFactor; how fast can the zombies move
private int zombieX; where are the zombies
private int zombieY;
private boolean zombieAlive; are the zombies alive
private char board;
private FlowLayout layout; the simplest Java GUI layout
public void initializeBoardchar board
this will set up the board by placing the walls and door
public void displayBoardchar board
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