Question
Create an Enemy class, Player class, and GameObject class for your game.java. The Enemy and Player (sub) classes should inherit from the GameObject (super) class.
Create an Enemy class, Player class, and GameObject class for your game.java. The Enemy and Player (sub) classes should inherit from the GameObject (super) class. Create a player and a few enemies. Create the basic movements (left/right/up/down) for the player. Develop a menu in the main program that allows the player to move around.
The main program will be rather simple since most everything is handled in the classes. import java.util.*; public class game { public static void main (String[] args) { Scanner in = new Scanner(System.in); String Choice = ""; // creating the player will initialize the world Player Kirk = new Player("Kirk",'K'); // create some enemies here in random locations while (!Choice.equals("q")) { Kirk.PrintWorld(); System.out.println("Enter your command: "); Choice = in.nextLine(); if (Choice.equals("a")) Kirk.MoveLeft(); if (Choice.equals("d")) Kirk.MoveRight(); if (Choice.equals("w")) Kirk.MoveUp(); if (Choice.equals("s")) Kirk.MoveDown(); } } }
GameObject SuperClass Description Variables static char World[] [ ] = new char [41] [21] ; This is the character array that will store what is at each X,Y location. It is static so there is int Xpo3, Ypos char Avatar Methods PrintWorld() only one World for all objects X,Y location of the game object. The top left of the screen will be 1,1 The character that will be displayed on the screen Description This will print the World to the screen. Example code for (int y=1; y?=20; y++) for {int x=1; xStep 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