Commit f8e20024 by BellCodeEditor

save project

parent b7080dc1
Showing with 85 additions and 0 deletions
import turtle
#背景颜色
screen=turtle.Screen()
screen.bgcolor("pink")
#写字
x=turtle.Pen()
x.penup()
x.goto(100,-100)
x.write("Hi,诺依~\n用python写电子贺卡真是太有趣啦~\n我也喜欢python~",font=("Times",13,"normal"))
x.hideturtle()
#画爱心
a=turtle.Pen()
a.pencolor("red")
a.fillcolor("red")
a.begin_fill()
a.pensize(5)
a.left(45)
a.forward(100)
a.circle(50,180)
a.right(90)
a.circle(50,180)
a.forward(100)
a.end_fill()
a.hideturtle()
turtle.done()
\ No newline at end of file
import pygame
from pygame import locals
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.Clock()
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y = 240,120
position = [(180,90),(180,120),(210,120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
x += 30
position.append((x,y))
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, position[-1])
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(food,(360,300))
screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
\ No newline at end of file
import turtle
import turtle
x = turtle.Pen()
x.pensize(3)
x.speed(9)
x.pencolor("red")
x.fillcolor("red")
x.begin_fill()
x.left(90)
x.forward(100)
x.right(90)
x.goto(0,0)
x.circle(50,180)
x.end_fill()
x.hideturtle()
turtle.done()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment