Commit 916e0308 by BellCodeEditor

save project

parent d5739bd2
Showing with 6 additions and 3 deletions
import pygame
from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
apple_x=360
apple_y=300
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -41,7 +42,9 @@ while True:
if event.key == locals.K_DOWN and setheading != "up":
setheading = 'down'
snake_head = down
if x==apple_x and y==apple_y:
apple_x=random.randint(0,660)
apple_y=random.randint(0,480)
# 设置贪吃蛇的头部坐标
if setheading == "right":
x += 30
......
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