Commit 3828667e by BellCodeEditor

save project

parent 6df52525
Showing with 8 additions and 2 deletions
import pygame
from pygame import locals
from random import randint
x,y=240,120
pusition=[(180,90),(180,120),(210,120),(x,y)]
apple_x=360
apple_y=300
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
......@@ -45,10 +48,13 @@ while True:
y+=30
pusition.append((x,y))
pusition.pop(0)
if x==apple_x and y==apple_y:
apple_x=randint(0,660)
apple_y=randint(0,480)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right,pusition[-1])
screen.blit(snake_head,pusition[-1])
# 将贪吃蛇的身体画上去
for i in range(len(pusition)-1):
screen.blit(body,pusition[i])
......@@ -57,7 +63,7 @@ while True:
#screen.blit(body, (180, 120))
#screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (apple_x, apple_y))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
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