A simple Spaceship java game
4966
$$
- Posted:
- Proposals: 0
- Remote
- #38442
- Archived
Description
Experience Level: Intermediate
Need to create a simple Spaceship game with one player and three enemy ships. The player's ship can move left and right and can shoot enemy ships. The enemy ships are programmed to repeatedly move left and right. The game finishes when all enemies are destroyed.
The program begins by asking the user to input the initial position and velocity for each enemy ship.
* Initial x position: The left boundary of the coordinate system is at position -6, the right boundary is at position 6, and the middle of the screen is at position 0. Your program does not need to check if the user enters a position out of this range.
* Initial velocity: The user may enter either -1 or 1. Your program does not need to check if the user enters an invalid velocity. A velocity of -1 causes the enemy to move left, while a velocity of 1 causes the enemy to move right.
The player's ship is placed at position 0. Then, the game enters a loop in which the current game state and score is printed to the screen, and the user is asked to enter a move. The move can be one of 3 options:
* l: move the player's ship one space to the left if it would not move out of bounds.
* r: move the player's ship one space to the right if it would not move out of bounds.
* f: fire a bullet straight ahead, destroying any and all ships in its path.
Each time a move is performed, the enemies must move before the player's own move happens. The enemy moves by moving left or right (depending on its velocity) until hitting a boundary, and then turning around and heading in the other direction.
Each time an enemy is shot down, 1 point is awarded, plus a bonus of 5-N points if the previous ship was shot down N moves ago (including l/r/f moves) if N 5. Once all enemy ships have been destroyed, the game loop terminates, and the message You won! is printed.
The program begins by asking the user to input the initial position and velocity for each enemy ship.
* Initial x position: The left boundary of the coordinate system is at position -6, the right boundary is at position 6, and the middle of the screen is at position 0. Your program does not need to check if the user enters a position out of this range.
* Initial velocity: The user may enter either -1 or 1. Your program does not need to check if the user enters an invalid velocity. A velocity of -1 causes the enemy to move left, while a velocity of 1 causes the enemy to move right.
The player's ship is placed at position 0. Then, the game enters a loop in which the current game state and score is printed to the screen, and the user is asked to enter a move. The move can be one of 3 options:
* l: move the player's ship one space to the left if it would not move out of bounds.
* r: move the player's ship one space to the right if it would not move out of bounds.
* f: fire a bullet straight ahead, destroying any and all ships in its path.
Each time a move is performed, the enemies must move before the player's own move happens. The enemy moves by moving left or right (depending on its velocity) until hitting a boundary, and then turning around and heading in the other direction.
Each time an enemy is shot down, 1 point is awarded, plus a bonus of 5-N points if the previous ship was shot down N moves ago (including l/r/f moves) if N 5. Once all enemy ships have been destroyed, the game loop terminates, and the message You won! is printed.
Cac M.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
0%
Last project
11 May 2024
Australia
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies