Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson3_diy4
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
c77235d3
authored
4 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
4c156670
c14718l1354p256a13985/wx838194
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
snake.py
snake.py
View file @
c77235d3
...
@@ -20,7 +20,7 @@ down = pygame.image.load('down.png') # 头 朝下
...
@@ -20,7 +20,7 @@ down = pygame.image.load('down.png') # 头 朝下
mf
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
18
)
mf
=
pygame
.
font
.
Font
(
'neuropol.ttf'
,
18
)
x
,
y
=
240
,
120
x
,
y
=
240
,
120
position
=
[(
210
,
120
),
(
x
,
y
)]
position
=
[(
210
,
120
),
(
x
,
y
)]
s
=
0
s
=
4
0
t
=
3
t
=
3
long
=
0
long
=
0
setheading
=
"right"
setheading
=
"right"
...
@@ -69,7 +69,7 @@ while True:
...
@@ -69,7 +69,7 @@ while True:
screen
.
blit
(
snake_head
,
position
[
-
1
])
screen
.
blit
(
snake_head
,
position
[
-
1
])
info
=
'SOCRE:'
+
str
(
s
)
+
'!'
info
=
'SOCRE:'
+
str
(
s
)
+
'!'
text
=
mf
.
render
(
info
,
True
,(
0
,
0
,
0
))
text
=
mf
.
render
(
info
,
True
,(
0
,
0
,
0
))
screen
.
blit
(
text
,(
54
0
,
10
))
screen
.
blit
(
text
,(
45
0
,
10
))
# 将果实画上去
# 将果实画上去
screen
.
blit
(
food
,
(
apple_x
,
apple_y
))
screen
.
blit
(
food
,
(
apple_x
,
apple_y
))
if
x
==
apple_x
and
y
==
apple_y
:
if
x
==
apple_x
and
y
==
apple_y
:
...
@@ -79,12 +79,14 @@ while True:
...
@@ -79,12 +79,14 @@ while True:
t
+=
0.5
t
+=
0.5
if
s
>=
10
and
s
<
20
:
if
s
>=
10
and
s
<
20
:
t
+=
0.7
t
+=
0.7
if
s
>=
20
:
if
s
>=
20
and
s
<
40
:
t
+=
1
t
+=
1
if
s
>=
40
:
t
+=
2
;
s
+=
1
s
+=
1
long
=
1
long
=
1
apple_x
=
random
.
randint
(
2
,
2
2
)
*
30
-
30
apple_x
=
random
.
randint
(
2
,
2
1
)
*
30
-
30
apple_y
=
random
.
randint
(
2
,
1
6
)
*
30
-
30
apple_y
=
random
.
randint
(
2
,
1
5
)
*
30
-
30
if
long
==
0
:
if
long
==
0
:
position
.
pop
(
0
)
position
.
pop
(
0
)
if
x
<
0
or
y
<
0
or
x
>
630
or
y
>
450
:
if
x
<
0
or
y
<
0
or
x
>
630
or
y
>
450
:
...
...
This diff is collapsed.
Click to expand it.
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