Commit 9f784819 by BellCodeEditor

save project

parent e273e0b5
apple.png

165 Bytes

bg.png

6.04 KB

body.png

164 Bytes

down.png

162 Bytes

left.png

162 Bytes

File added
'''
lis=[2,8,3,6,5,3,8]
a=[]
for i in :
if == :
a.append(i)
print(a)
for j in a:
lis.pop(j)
print(lis)
'''
count=0
while count<50:
count+=1
if count%2==0:
continue
print(count,end='')
\ No newline at end of file
right.png

162 Bytes

import pygame
from pygame import locals
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
fps = 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')
x,y = 240,120
liebiao=[(180,90),(180,120),(210,120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
x+=30
liebiao.append((x,y))
liebiao.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
for i in range(len(liebiao)-1):
screen.blit(body,(liebiao[i]))
screen.blit(right, (x, y))
# 将贪吃蛇的身体画上去
#screen.blit(body, (210, 120))
#screen.blit(body, (180, 120))
#screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
fps.tick(1)
\ No newline at end of file
up.png

162 Bytes

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