Answered step by step
Verified Expert Solution
Link Copied!

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 his/her score is zero (shown in the status window). There will be afence (the Xs) around the 12 x 12 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 2 ways. 1) Get out of the room via the door, thus ending the level. You get 100*(currentLevel +1) points 2) 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 10% 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 2% more often (i.e. for level 2 there will be five robots with 12%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.setFont(new Font("Courier New",Font.PLAIN,12));
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 =5; // location of door
private final int doorY =0;
private final int numRows =12; // dimensions for playing area
private final int numCols =12;
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 initializeBoard(char board [][])
//this will set up the board by placing the walls and door
public void displayBoard(char board [][])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions