Commit fc30384e by BellCodeEditor

save project

parent c6755914
Showing with 12 additions and 1 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -21,6 +21,17 @@ while True: ...@@ -21,6 +21,17 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.iftype == locals.KEYDOWN:
if event.type == locals.K_RIGHT and setheading !='left':
setheading = 'right'
if event.type == locals.K_LEFT and setheading != 'right':
setheading = 'left'
if event.type == locals.K_UP and setheading != 'down':
setheading = 'up'
if event.type == locals.K_DOWN and setheading != 'up':
setheading == 'down'
if
# 将背景图画上去 # 将背景图画上去
x += 30 x += 30
body2.append((x, y)) body2.append((x, y))
......
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