Commit b2603901 by BellCodeEditor

save project

parent 9cd0652a
Showing with 7 additions and 3 deletions
import pygame
from pygame import locals#locals为pygame子模块(必写)
from random import *
import random
#初始化pygame,为使用硬件做准备
pygame.init()
#创建一个窗口
......@@ -14,7 +14,7 @@ body=pygame.image.load('body.png')
left=pygame.image.load('left.png')
up=pygame.image.load('up.png')
down=pygame.image.load('down.png')
my_font=pygame.image.Font('neuropol.ttf',18)#字体
my_font=pygame.font.Font('neuropol.ttf',18)#字体
x,y=240,120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
......@@ -42,12 +42,16 @@ while True:
#设置贪吃蛇的头部坐标
if setheading=='right':
x+=30
snake_head=right
elif setheading=='left':
x-=30
snake_head=left
elif setheading=='up':
y-=30
snake_head=up
else:
y+=30
snake_head=down
position.append((x,y))
#刷新苹果
if x==a_x and y==a_y:
......@@ -71,7 +75,7 @@ while True:
screen.blit(food,(a_x,a_y))
#绘制分数
info='Score:'+str(score)
text=my_font.render(info,Ture,(0,0,0))
text=my_font.render(info,True,(0,0,0))
screen.blit(text,(540,10))
#刷新画面
pygame.display.update()
......
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