Commit 51fccce3 by BellCodeEditor

auto save

parent 6f7791a0
Showing with 10 additions and 4 deletions
import pygame
import random
from pygame import locals
# 初始化pygame,为使用pygame做准备
pygame.init()
sab = pygame.image.load('bg.png')
......@@ -11,6 +13,8 @@ body = pygame.image.load('body.png')
sb=pygame.display.set_mode((660,480))
FPSCLOCK = pygame.time.Clock()
x, y = 240, 120
apple_x = 360
apple_y = 480
lb = [(180,90),(180,120),(210,120),(x,y)]
fx = "right"
......@@ -39,12 +43,14 @@ while True:
#x += 30
lb.append((x,y))
lb.pop(0)
if apple_x and apple_y == x and y:
apple_x = random.randint(0,660)
apple_y = random.randint(0.480)
sb.blit(sab,(0,0))
sb.blit(right, lb[-1])
#sb.blit(right,(x,y))
#sb.blit(sab,(0,0))
sb.blit(food,(120,300))
sb.blit(food,(apple_x,apple_y))
#sb.blit(right,(x,y))
for i in range(len(lb)-1):
sb.blit(body, lb[i])
......@@ -53,4 +59,4 @@ while True:
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
FPSCLOCK.tick(3)
\ No newline at end of file
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