Project 1: Console-based Scorched Earth Clone

For this project you will be implementing a console-based version of a simplified version of the game you designed in Project 0. This should be a straight-forward application of the skills you learned in CIS3022; you will be using the UserInput class and System.out statements to do all of the I/O. However, since everything will be displayed in ASCII characters and can only be printed from top to bottom and from left to right, you will have to use a not-so-intuitive approach to draw the screens.

Below I have specified a class and method structure for you to follow. This is probably not the best solution to the problem, so you are welcome to think up your own design, but you are strongly encouraged to use an MVC architecture (separate user interface from data/processing); if you do not, you will essentially be starting from scratch with Project 2.

Classes

  1. World
    1. World(int numPlayers, int width, int height, int playerWidth, int playerHeight, double gravity)
    2. void init() // Randomly generate land and players' positions
    3. void reset() // Return everything to initial state
    4. int getPlayerLocation(int player)
    5. int getAltitude(int x) // Get the height of the land at a given x position
    6. int getLastShotHeight(int x) // Height of last shot for a given x (-1 if last shot is not present at x)
    7. void resetLastShot() // Stop displaying last shot
    8. int doShot(int playerIndex, int velocity, int angle) // Player fires a shot with a given velocity and angle.
    9. boolean isDead(int playerIndex)
  2. Player
    1. Player(int width, int height, int xPos, int health)
    2. int getWidth()
    3. int getHeight()
    4. int getPos()
    5. int getHealth()
    6. void setHealth(int newHealth)
    7. boolean isAlive()
  3. Shot
    1. Shot(int x, int y, int velocity, int angle, int power)
    2. getYForX(int x) // When shot occupies given x, what is it's y?
    3. getPower() // Amount shot takes from health
  4. ConsoleInterface
    1. static void main(String[] args)
    2. String printWorld(World world)
    3. Any other helper methods you deem appropriate

You will need to understand some basic physics for this. You might try googling "trajectory equations". I excluded time from this interface but calculate it under the covers (using currentX and initialX). Remember to convert between degrees and radians!

Your output should be similar to that shown below. I don't care if you use different characters or change your phrasing or whatever - I'm not going to be grading you based on diff

Sample Output

How many players do you have?
3
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     @@@                                        
                                     @@@                                        
                                     @@@                                    T   
                                    T T               @@@  TTTTTTT T   T  TT T  
                                  TT   TT             @@@TT       T TTT TT    TT
                               TTT       TTTT       TT@@@                       
                          T   T              T TT TT  TT                        
               @@@     TTT TTT                T  T                              
  T       TTT  @@@ TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
********************************************************************************
Player 1: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
45
Enter a velocity between 1 and 100: 
20
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                  ******                                        
                              ****      ****                                    
                           ***       @@@    **                                  
                         **          @@@      **                                
                        *            @@@        **                          T   
                      **            T T           *   @@@  TTTTTTT T   T  TT T  
                     *            TT   TT          ** @@@TT       T TTT TT    TT
                    *          TTT       TTTT       TT@@@                       
                   *      T   T              T TT TT  TT                        
               @@@*    TTT TTT                T  T                              
  T       TTT  @@* TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Player 2: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
140
Enter a velocity between 1 and 100: 
15
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                       *********                                                
                    ***         **                                              
                   *              **                                            
                 **                 *@@@                                        
                *                    *@@                                        
               *                     @@@                                    T   
              *                     T T               @@@  TTTTTTT T   T  TT T  
             *                    TT   TT             @@@TT       T TTT TT    TT
            *                  TTT       TTTT       TT@@@                       
           *              T   T              T TT TT  TT                        
          *    @@@     TTT TTT                T  T                              
  T      *TTT  @@@ TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Player 3: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
140
Enter a velocity between 1 and 100: 
15
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     XXX*********                               
                                     XXX         **                             
                                     XXX           **                       T   
                                    T T              *@@@  TTTTTTT T   T  TT T  
                                  TT   TT             *@@TT       T TTT TT    TT
                               TTT       TTTT       TT@@@                       
                          T   T              T TT TT  TT                        
               @@@     TTT TTT                T  T                              
  T       TTT  @@@ TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Player 1: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
45
Enter a velocity between 1 and 100: 
22
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     ********                                   
                                 ****        ****                               
                              ***                ***                            
                            **                      **                          
                           *         XXX              **                        
                         **          XXX                *                       
                       **            XXX                 **                 T   
                      *             T T               @@@  TTTTTTT T   T  TT T  
                     *            TT   TT             @@@TT       T TTT TT    TT
                    *          TTT       TTTT       TT@@@                       
                   *      T   T              T TT TT  TT                        
               @@@*    TTT TTT                T  T                              
  T       TTT  @@* TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Player 3: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
135
Enter a velocity between 1 and 100: 
20
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                ******                                          
                            ****      ****                                      
                          **              ***                                   
                        **                   **                                 
                      **                       *                                
                     *                          **                              
                   **                XXX          *                             
                  *                  XXX           *                            
                 *                   XXX            *                       T   
                *                   T T              *@@@  TTTTTTT T   T  TT T  
               *                  TT   TT             *@@TT       T TTT TT    TT
              *                TTT       TTTT       TT@@@                       
             *            T   T              T TT TT  TT                        
            *  @@@     TTT TTT                T  T                              
  T       TTT  @@@ TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Player 1: Enter an angle between 0 and 180 (0 is due-east and 180 is due-west): 
45
Enter a velocity between 1 and 100: 
21
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                    ******                                      
                                ****      ****                                  
                             ***              ***                               
                           **        XXX         **                             
                         **          XXX           **                           
                        *            XXX             *                      T   
                      **            T T               XXX  TTTTTTT T   T  TT T  
                     *            TT   TT             XXXTT       T TTT TT    TT
                    *          TTT       TTTT       TTXXX                       
                   *      T   T              T TT TT  TT                        
               @@@*    TTT TTT                T  T                              
  T       TTT  @@* TT T                                                         
TT TT  TTT   TT@@@T  T                                                          
     TT        TTT                                                              
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
Congratulations Player: 1 You Win!!
Play again? (y/n)