You will implement a version of the classic “space invaders” game, in which the player battles against an army of invading monsters.
In this game, the user uses the arrow keys to control a space ship that can move along the horizontal axis. Pressing the space key will cause the ship to shoot a single bullet, which will move at a constant speed, starting from the current position of the ship. If the bullet hits an enemy, both the enemy and the bullet will be removed from the game. If the bullet leaves the visible area of the screen, it will be removed from the game. There may be multiple bullets in flight at the same time. If no enemies remain, the player has won, and the game ends.
The enemies are initially arranged in rows. They move together at a regular time interval; initially, this time interval is one second, but as the game progresses, the time interval will get smaller and smaller, causing them to move increasingly fast. The enemies move horizontally (left or right), until the reach the end of the window, whereupon they will move one row closer to the player, and then continue moving horizontally in the opposite direction (if they were moving left in the previous row, they will move right in the subsequent row), until they again reach the end of the window. Please see the provided video for an example of enemy movement. If an enemy touches the player’s ship, the player has lost, and the game ends.
You may choose to implement any of the following optional components: enemies that can shoot back; attractive and colorful graphics; scoring; a high-score table.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import turtle
import time

# This variable store the horizontal position
# of the player's ship. It will be adjusted
# when the user press left and right keys, and
# will be used by the frame() function to draw
# the ship. The ship never moves vertically, so
# we don't need a variable to store its y position.
userx = 0

# This variable is a list of enemies currently in
# the game. Each enemy is represented by a tuple
# containing its x,y position as well as a string
# indicated the enemy's current direction of travel
# (either left or right).
# Your final game should include more enemies, although
# the exact arrangement is up to you.
enemies = []

# This variable is a list of all bullets currently
# in the game. It is a list of tuples of (x,y)
# coordinates, one for each bullet. An elements will
# be added when a new bullet is fired, and removed
# when a bullet is destroyed (either by leaving
# the screen or by hitting an enemy).
bullets = []

# This variable is checked by the game's main
# loop to determine when it should end. When
# the game ends (either when the player's ship
# is destroyed, or when all enemies have been
# destroyed), your code should set this variable
# to True, causing the main loop to end.
gameover = False

def frame():
    global userx
    signature: () -> NoneType
    Given the current state of the game in
    the global variables, draw all visual
    elements on the screen: the player's ship,
    the enemies, and the bullets.
    Please note that this is your only function
    where drawing should happen (i.e. the only
    function where you call functions in the
    turtle module). Other functions in this
    program merely update the state of global
    This function also should not modify any
    global variables.
    Hint: write this function first!
    turtle.setup(800, 600)
$70.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats