Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson2_diy1
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
5acb47b8
authored
May 16, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
f7309ab6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
snake.py
snake.py
View file @
5acb47b8
...
@@ -27,13 +27,12 @@ while True:
...
@@ -27,13 +27,12 @@ while True:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
and
setheading
!=
right
:
if
event
.
key
==
locals
.
K_RIGHT
and
setheading
!=
right
:
setheading
=
'right'
setheading
=
'right'
snakehead
=
right
snakehead
=
right
x
=
x
+
30
if
event
.
key
==
locals
.
K_LEFT
and
setheading
!=
left
:
if
event
.
key
==
locals
.
K_LEFT
and
setheading
!=
left
:
setheding
=
'left'
setheding
=
'left'
snakehead
=
left
snakehead
=
left
x
=
x
-
30
if
event
.
key
==
locals
.
K_DOWN
and
setheading
!=
down
:
if
event
.
key
==
locals
.
K_DOWN
and
setheading
!=
down
:
setheading
=
'down'
setheading
=
'down'
snakehead
=
down
snakehead
=
down
...
@@ -42,7 +41,15 @@ while True:
...
@@ -42,7 +41,15 @@ while True:
setheading
=
'up'
setheading
=
'up'
snakehead
=
up
snakehead
=
up
if
setheading
==
'right'
:
x
=
x
+
30
elif
setheading
==
'left'
:
x
=
x
-
30
elif
setheading
==
'down'
:
y
=
y
+
30
else
:
y
=
y
-
30
position
.
append
((
x
,
y
))
position
.
append
((
x
,
y
))
position
.
pop
(
0
)
position
.
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