Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson2_diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4c52ddd3
authored
Feb 24, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
2a143850
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletions
snake.py
snake.py
View file @
4c52ddd3
...
...
@@ -3,7 +3,8 @@ from pygame import locals
FPSCLOCK
=
pygame
.
time
.
Clock
()
# 初始化pygame,为使用硬件做准备
pygame
.
init
()
b
=
"right"
h
=
right
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
x
,
y
=
240
,
120
...
...
@@ -18,6 +19,20 @@ while True:
if
event
.
type
==
locals
.
QUIT
:
# 接收到退出事件后退出程序
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
and
b
!=
"left"
:
b
=
"right"
h
=
right
if
event
.
key
==
locals
.
K_LEFT
and
b
!=
"right"
:
b
=
"left"
h
=
left
if
event
.
key
==
locals
.
K_UP
and
b
!=
"down"
:
b
=
"up"
h
=
up
if
event
.
key
==
locals
.
K_DOWN
and
b
!=
"up"
:
b
=
"down"
h
=
down
x
+=
30
a
.
append
((
x
,
y
))
a
.
pop
(
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment