闪避球游戏
闪避球游戏,Python海龟作图游戏。
规则:吃三角可以加5分,被球碰到游戏结束,前后左右按键可以移动方块,100分可以赢。
import turtle
import random
import time
w,h = 500,400
screen = turtle.Screen()
screen.delay(0)
screen.bgcolor('black')
screen.setup (w,h)
screen.title("闪避球游戏__作者:Childoge,规则:100分可以赢,躲避球,吃三角")
mainball = turtle.Turtle(shape= 'square')
mainball.shapesize(1,1)
mainball.penup()
mainball.speed(5)
mainball.color('white')
def moveright():
if mainball.xcor() + 20 < w / 2:
mainball.setx(mainball.xcor()+10)
def moveleft():
if mainball.xcor() - 10 > -w / 2:
mainball.setx(mainball.xcor()-10)
def moveup():
if mainball.ycor()+10 < h/2:
mainball.sety(mainball.ycor()+10)
def movedown():
if mainball.ycor() - 20 > -h /