Commit cf22b5c1 by BellCodeEditor

save project

parent 4fdeea6c
Showing with 8 additions and 1 deletions
import pygame import pygame
import random
from pygame import locals from pygame import locals
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
...@@ -22,6 +23,7 @@ x,y=240, 120 ...@@ -22,6 +23,7 @@ x,y=240, 120
z=[(180, 90),(180, 120),(210, 120),(x,y)] z=[(180, 90),(180, 120),(210, 120),(x,y)]
fx='right' fx='right'
fx_t=right fx_t=right
apple_x,apple_y=360, 300
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -53,6 +55,11 @@ while True: ...@@ -53,6 +55,11 @@ while True:
y+=30 y+=30
else: else:
y-=30 y-=30
if apple_x==x and apple_y==y:
apple_x=random.randint(0,660)
apple_y=random.randint(0,480)
z.pop(0) z.pop(0)
z.append((x,y)) z.append((x,y))
# 将背景图画上去 # 将背景图画上去
...@@ -63,7 +70,7 @@ while True: ...@@ -63,7 +70,7 @@ while True:
for i in range(len(z)-1): for i in range(len(z)-1):
screen.blit(body,z[i]) screen.blit(body,z[i])
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (apple_x,apple_y))
f.tick(3) f.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