Commit 89d91c9c by BellCodeEditor

save project

parent 4df08018
Showing with 22 additions and 1 deletions
import pygame
from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -12,13 +12,34 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
left= pygame.image.load('left.png')
up= pygame.image.load('up.png')
my_font= pygame.font.Font('neuropol.ttf',18)
x,y=240,120
position=[(180,90),(180,120),(210,120),(x,y)]
apple_x = 360
apple_y = 360
setheadin = 'right'
snake_head=right
scre=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.QUIT:
if event.key == locals.k_RIGHT and setheadin !="left":
setheadin = 'right'
snake_head=right
if event.key == locals.k_RIGHT and setheadin !="right":
setheadin = 'right'
snake_head=right
if event.key == locals.k_RIGHT and setheadin !="down":
setheadin = 'up'
snake_head=up
if event.key == locals.k_RIGHT and setheadin !="up":
setheadin = 'down'
snake_head=down
x +=30
position.append((x,y))
position.pop(0)
......
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