While completing this assignment you will learn important concepts of the software design:
1. Using list variables
2. Keyboard binding
3. Randomization
4. While-loops
5. Collision detection
Copy the code provided in the template.
To earn the mark in the respective range:
Level B
1. Change the graphics.
2. Use at least 2 external images, for example, the background and one of the ‘turtles’.
3. Change the boundaries.
4. Relocate the score.
5. Create a win message.
Level A
In addition to Level B requirements:
1. Use at least 3 external images, for example, the background and two ‘turtles’, including the list.
2. Create next level.
3. Use font(s).
Level A+
In addition to Level A and B requirements:
1. Use extra turtle(s) – make them not only ‘chase’ but also ‘escape’ with the deduction of the score.
2. Create a ‘losing’ screen.
3. Include the results of independent research to provide the user with outstanding experience.
my code is:
import turtle
import math
import random
import time
wn = turtle.Screen()
wn.setup(1000, 667)
wn.tracer(2)
wn.bgpic("space.gif")
wn.register_shape("ship.gif")
wn.addshape("ship.gif")
wn.register_shape("bigship.gif")
wn.addshape("bigship.gif")
mypen = turtle.Turtle(visible=False)
mypen.hideturtle()
mypen.pensize(3)
mypen.color('white')
player = turtle.Turtle()
player.shape("bigship.gif")
player.penup()
player.speed (0)
maxAims = 6
aims = []
for count in range(maxAims):
aims.append(turtle.Turtle())
aims[count].shape("ship.gif")
aims[count].penup()
aims[count].speed(0)
aims[count].setposition(random.randint (-280, 280), random.randint (-280, 280))
speed = 1
score = 0
def turnleft():
player.left(30)
def turnright():
player.right(30)
def increasespeed():
global speed
speed += 0.5
def decreasespeed():
global speed
if speed > 0:
speed -= 1
turtle.listen()
turtle.onkey (turnleft, 'Left')
turtle.onkey (turnright, 'Right')
turtle.onkey (increasespeed, 'Up')
turtle.onkey (decreasespeed, 'Down')
while True:
player.forward(speed)
if player.xcor() > 480 or player.xcor() < -480:
player.right(180)
if player.ycor() > 310 or player.ycor() < -310:
player.right(180)
for count in range(maxAims):
aims[count].forward(3)
if aims[count].xcor()>480 or aims[count].xcor()<-480:
aims[count].right(180)
if aims[count].ycor()>480 or aims[count].ycor()<-480:
aims[count].right(180)
d = math.sqrt(math.pow(player.xcor()-aims[count].xcor(),2)+math.pow(player.ycor()-aims[count].ycor(),2))
if d < 70:
aims[count].hideturtle()
aims[count].setposition(-300, -300)
score += 1
mypen.undo()
mypen.penup()
mypen.hideturtle()
mypen.color('white')
mypen.setposition(-500, 300)
scorestring = "Score: %s" %score
mypen.write(scorestring, False, align="left", font=("Arial", 14, "normal"))
if d < 40:
aims[count].hideturtle()
aims[count].setposition(-300, -300)
score += 1
mypen.undo()
mypen.penup()
mypen.color('white')
mypen.hideturtle()
mypen.setposition(-500, 300)
scorestring = "Score: %s" %score
mypen.write(scorestring, False, align="left", font=("Arial", 14, "normal"))
if score == 6:
player.hideturtle()
break
I'm having the issue where when I angle the player and it moves and hits certain parts in the bottom it adds to the score. I'd also like some help if anyone could start doing the other part (A and A+).