Commit 72f311ea by BellCodeEditor

auto save

parent ef7dc539
class Person:
def __init__(self,name,age):
self.name=name
self.age=age
class Teacher():
def __init__(self):
self.name="lk"
self.age="12"
def skill(self,subject):
print("你今天教了"+subject)
lk=Cat()
lk.eat("肉")
apple.png

2.05 KB

bg.png

22.5 KB

body.png

1.4 KB

down.png

2.01 KB

a=int(input("输入长"))
b=int(input("输入宽"))
print("长方形的面积是",a*b,sep="")
print("长方形的周长是",a*2+b*2,sep="")
left.png

2.07 KB

import turtle
turtle.dot(20,"red")
turtle.done()
\ No newline at end of file
File added
right.png

2.05 KB

import turtle
turtle.pencolor("black")
turtle.begin_fill()
for i in range(4):
turtle.forward(100)
turtle.right(90)
turtle.end_fill()
turtle.goto(0,100)
for i in range(4):
turtle.forward(100)
turtle.right(90)
turtle.goto(-100,100)
turtle.begin_fill()
for i in range(4):
turtle.forward(100)
turtle.right(90)
turtle.end_fill()
turtle.goto(-100,0)
for i in range(4):
turtle.forward(100)
turtle.right(90)
turtle.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))
a=pygame.time.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')
up = pygame.image.load('up.png')
left = pygame.image.load('left.png')
down = pygame.image.load('down.png')
x,y=240,120
c=[(180,90),(180,120),(210,120),(x,y)]
d="right"
sb=right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type ==locals.KEYDOWN:
if event.key==locals.K_RIGHT and d!="left":
d="right"
sb=right
if event.key==locals.K_LEFT and d!="right":
d="left"
sb=left
if event.key==locals.K_UP and d!="down":
d="up"
sb=up
if event.key==locals.K_DOWN and d!="up":
d="down"
sb=down
if d=="right":
x+=30
if d=="left":
x-=30
if d=="up":
y-=30
if d=="down":
y+=30
c.append((x,y))
c.pop(0)
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(sb, c[-1])
for i in range(len(c)-1):
screen.blit(body,c[i])
# 将贪吃蛇的身体画上去
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
a.tick(3)
\ No newline at end of file
up.png

2.05 KB

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