Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- import os
- wn = turtle.Screen()
- wn.bgcolor("black")
- wn.title("Space Invaders")
- border_pen = turtle.Turtle()
- border_pen.speed(0)
- border_pen.color("white")
- border_pen.penup()
- border_pen.setposition(-300,-300)
- border_pen.pensize(3)
- for side in range(4):
- border_pen.fd(600)
- border_pen.lt(90)
- border_pen.hideturtle()
- player = turtle.Turtle()
- player.color("blue")
- player.shape("triangle")
- player.penup()
- player.speed(0)
- player.setposition(0, -250)
- player.setheading(90)
- playerspeed = 15
- def move_left():
- x = player.xcor()
- x -= playerspeed
- if x < -280:
- x = -280
- player.setx(x)
- def move_right():
- x = player.xcor()
- x += playerspeed
- if x > 280:
- x = 280
- player.setx(x)
- turtle.listen()
- turtle.onkey(move_left, "Left")
- turtle.onkey(move_right, "Right")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement