Commit 9f457513 by BellCodeEditor

save project

parent d5739bd2

2.05 KB | W: | H:

557 Bytes | W: | H:

apple.png
apple.png
apple.png
apple.png
  • 2-up
  • Swipe
  • Onion skin

22.5 KB | W: | H:

362 KB | W: | H:

bg.png
bg.png
bg.png
bg.png
  • 2-up
  • Swipe
  • Onion skin

1.4 KB | W: | H:

2.14 KB | W: | H:

body.png
body.png
body.png
body.png
  • 2-up
  • Swipe
  • Onion skin

2.01 KB | W: | H:

518 Bytes | W: | H:

down.png
down.png
down.png
down.png
  • 2-up
  • Swipe
  • Onion skin

2.07 KB | W: | H:

508 Bytes | W: | H:

left.png
left.png
left.png
left.png
  • 2-up
  • Swipe
  • Onion skin

2.05 KB | W: | H:

514 Bytes | W: | H:

right.png
right.png
right.png
right.png
  • 2-up
  • Swipe
  • Onion skin
import pygame
from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
screen = pygame.display.set_mode((800, 600))
FPSCLOCK = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 背景
......@@ -19,7 +20,7 @@ down = pygame.image.load('down.png') # 头 朝下
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
ax,ay=360,300
setheading = "right"
snake_head = right
......@@ -52,7 +53,11 @@ while True:
else:
y += 30
position.append((x, y))
position.pop(0)
if ax==x and ay==y:
ax=random.randint(0,800)
ay=random.randint(0,600)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
......@@ -62,7 +67,7 @@ while True:
screen.blit(body, position[i])
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (ax, ay))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file

2.05 KB | W: | H:

510 Bytes | W: | H:

up.png
up.png
up.png
up.png
  • 2-up
  • Swipe
  • Onion skin
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