Commit 34e1745c by BellCodeEditor

save project

parent d5739bd2
Showing with 11 additions and 9 deletions
import pygame
from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
screen = pygame.display.set_mode((6600, 4800))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 背景
......@@ -42,16 +41,19 @@ while True:
setheading = 'down'
snake_head = down
# 设置贪吃蛇的头部坐标
if setheading == "right":
x += 30
x += 1
elif setheading == "left":
x -= 30
x -= 1
elif setheading == "up":
y -= 30
y -= 1
else:
y += 30
y += 1
position.append((x, y))
food_x = random.randint(0,660)
food_y = random.randint(0,480)
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
......@@ -65,4 +67,4 @@ while True:
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
FPSCLOCK.tick(8000)
\ 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