COSC 1336, Project 2: Space InvaderObjectivesThis is one of three major programming projects this semester. You may  collaborate on this project, but the code must be yours. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Objectives include:•Call and write methods with parameters and return values.•Use the DrawingPanel, Graphics, and Color classes.•Use for loops and if statements to control assignments.Hand-in RequirementsSubmit thru Canvas.•Project2.javaIntroductionIn this project you will write a program that could be the basis for a simple version of the space invaders video game. This project will involve graphics and animation. (See in Canvas->Files This project has several parts and should be started early.Make sure your program and each method is preceded by a descriptive comment.Part 1: SetupStart a new project in Dr. Java. Load  into Dr. Java and change the name of the class to Project2. Also get a copy of from Canvas->File and put it into the same directory as•Change drawCircles to startGame.•In startGame, change  loop variable ‘I’  to ‘time’ and make the time go up to 1000 instead of 90.•Remove everything from the body of the for loop except for the sleep method. •In the main method, before the call to startGame, print the following on the screen in black at position x = 10 and y = 15:Project 2 by YOURNAME.Replace YOURNAME with your full name.Part 2: The Patrol shipCreate class constants PATROL_Y initialized to 250 and PATROL_SIZE initialized to 20. For example, put public static final int PATROL_Y = 250; after the class header: public class Project2.Make a (non-constant) class variable called patrolX initialized to 270.For example, put public static int patrolX = 270; after the class constants.Write the method:public static void drawPatrol(Graphics g, Color c); that fills a square at x = patrolX, y = PATROL_Y, with side PATROL_SIZE in the given color. Do a Google for “Java Graphics fillRect to find a graphics method.Call drawPatrol(g, Color.GREEN) before the for loop statement. Get it working.Part 3: The enemy shipMake class constants ENEMY_Y and ENEMY_SIZE initialized to 20 and 30, respectively.Make a class variable enemyX initialized to 0.The enemy ship will be a red square with the given position and size.Write the method: public static void moveEnemyShipAndDraw(Graphics g); that draws the enemy ship first in white, then increment enemyX by 1, and then draws the ship again in red. Put a call to this method inside the for loop.Part 4: Moving the patrol shipMake integer constants RIGHT_ARROW = 39, LEFT_ARROW = 37, and UP_ARROW = 38.Write the method:public static void handleKeys(DrawingPanel panel, Graphics g);This will call panel.getKeyCode() that returns a code for a key. It returns 0 if no key has been pushed, and will return one of the above constants if the corresponding arrow key has been pushed.•The method handleKeys should do nothing if the returned key code is 0.•If the key code is RIGHT_ARROW or LEFT_ARROW, move the patrol ship to the right or left by 3 pixels, but do not let any part of the patrol ship move off the screen.To move the patrol ship:•draw the patrol ship in white (to erase the old one)•change patrolX•draw the patrol ship in greenCall the method handleKeys in the loop. You should be able to move the patrol ship by pushing the left and right arrows on the keyboard.Before using the arrow keys, make sure your drawing window is the active window by clicking the mouse in this window.Part 5: ShootingThe patrol ship will shoot a missile when the up arrow key is pushed.Make class variables patrolMissileX and patrolMissileY.Initialize patrolMissileY to 0.Make a contant PATROL_MISSILE_LENGTH initialized to 10.Write a method: public static void movePatrolMissileAndDraw(Graphics g); that moves the missile and draws it similar to moveEnemyShipAndDraw:•Do not draw anything if patrolMissileY is 0.•Otherwise, the missile as a vertical line with the stated length and x-position.•PatrolMissileY is the top of the line.•Draw the missile in white, move the missile up 5 pixels, and draw it again in black.•If the patrolMissileY is 0 or negative, do not draw the missile in black, but set patrolMissileY to 0.Call this method before the sleep in the loop.When the up arrow key is pushed and patrolMissileY is 0, set patrolMissileX to be the center of the patrol ship and set the top of the missile so that its bottom is one pixel above the top of the patrol ship (PATROL_Y).You should only be able to fire one missile at a time and the up arrow should not do anything if a missile is still displayed.Part 6: Detecting a hitMake a boolean class variable, hit, initialized to false; Write the method: public static boolean detectHit(); that returns true if the current missile has hit the enemy ship and false otherwise.There is a hit if the top of the missile is inside the enemy ship.For this to happen two thing must be true:•the x value of the top of the missile must be between the left and right sides of the enemy•the y value of the top of the missile must be between the top and bottom of the enemy.At the end of the loop in startGame, set hit to true if detectHit() returns true. Modify moveEnemyShipAndDraw so that if hit is true, the enemy ship is drawn in black and does not move. In this case, display the message:Enemy ship hit!in green on a line below the patrol ship.If the enemy ship moves off the screen or time runs out, Display the message:Enemy ship got away!in red on a line below the patrol ship.

Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.