Guest User

space invaders. wndow not responding

a guest
Aug 1st, 2020
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #space invaders -part 1
  2. #Set up the screen
  3. #python 2.7
  4. import turtle
  5. import os
  6. # set up screen
  7. wn = turtle.Screen()
  8. wn.bgcolor("black")
  9. wn.title("deadly hallows")
  10.  
  11. #Draw border
  12. border_pen = turtle.Turtle()
  13. border_pen.speed(0)
  14. border_pen.color("white")
  15. border_pen.penup()
  16. border_pen.setposition (-300,-300)
  17. border_pen.pendown()
  18. border_pen.pensize(3)
  19. for side in range(4):
  20.     border_pen.fd(600)
  21.     border_pen.lt(90)
  22.     border_pen.hideturtle()
  23.  
  24. #player turtle
  25. player = turtle.Turtle()
  26. player.color("blue")
  27. player.shape("triangle")
  28. player.penup()
  29. player.speed(0)
  30. player.setposition(0, -250)
  31.  
  32. Playerspeed = 15
  33. # Move the player left and right
  34. def move_left():
  35.         x = player.xcor()
  36.         x -= playerspeed
  37.         player.setx(x)
  38.         def move_right():
  39.             x=player.xcor()
  40.             x += playerspeed
  41.             player.setx(x)
  42.  
  43.  
  44. #keybord bindings
  45. turtle.listen()
  46. turtle.onkey(move_left, "left")
  47. turtle.onkey(move_right, "right")
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. delay = raw_input("press enter to finish.")
  55.  
RAW Paste Data