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
8b8d320b
authored
Jan 07, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
d8635ca3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
5 deletions
a.png
snake.py
两个群.png
吃豆人.py
a.png
0 → 100644
View file @
8b8d320b
453 KB
snake.py
View file @
8b8d320b
...
...
@@ -16,24 +16,56 @@ sj=pygame.time.Clock()
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
# 背景
a
=
pygame
.
image
.
load
(
'a.png'
)
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
food
=
pygame
.
image
.
load
(
'apple.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
left
=
pygame
.
image
.
load
(
'left.png'
)
up
=
pygame
.
image
.
load
(
'up.png'
)
down
=
pygame
.
image
.
load
(
'down.png'
)
z
=
[(
180
,
90
),(
180
,
120
),(
210
,
120
),(
x
,
y
)]
fx
=
'right'
snakehead
=
right
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
print
(
event
)
if
event
.
type
==
locals
.
QUIT
:
#叉号
# 接收到退出事件后退出程序
exit
()
x
+=
30
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_RIGHT
and
fx
!=
'left'
:
fx
=
'right'
snakehead
=
right
if
event
.
key
==
locals
.
K_LEFT
and
fx
!=
'right'
:
fx
=
'left'
snakehead
=
left
if
event
.
key
==
locals
.
K_UP
and
fx
!=
'down'
:
fx
=
'up'
snakehead
=
up
if
event
.
key
==
locals
.
K_DOWN
and
fx
!=
'up'
:
fx
=
'down'
snakehead
=
down
if
fx
==
'right'
:
x
+=
30
elif
fx
==
'left'
:
x
-=
30
elif
fx
==
'up'
:
y
-=
30
else
:
y
+=
30
# x+=30
z
.
append
((
x
,
y
))
z
.
pop
(
0
)
# 将背景图画上去
screen
.
blit
(
background
,
(
0
,
0
))
# 将贪吃蛇画上去
screen
.
blit
(
right
,
(
x
,
y
))
screen
.
blit
(
snakehead
,
(
x
,
y
))
# 将贪吃蛇的身体画上去
for
i
in
range
(
len
(
z
)
-
1
):
screen
.
blit
(
body
,
z
[
i
])
...
...
@@ -44,4 +76,4 @@ while True:
screen
.
blit
(
food
,
(
360
,
300
))
# 刷新画面
pygame
.
display
.
update
()
sj
.
tick
(
3
)
\ No newline at end of file
sj
.
tick
(
6
)
\ No newline at end of file
两个群.png
0 → 100644
View file @
8b8d320b
180 KB
吃豆人.py
0 → 100644
View file @
8b8d320b
import
sys
import
sys
import
webbrowser
sys
.
path
.
append
(
"libs"
)
url
=
'https://gui.makcoocode.com/?pid=do1PaAm4R5&fork=1&cburl=https
%253
A
%252
F
%252
Fgui.makcoocode.com
%252
Fshare
%253
Fpid
%253
Ddo1PaAm4R5
%2526
token
%253
D9eac3262-834e-11ed-9ec7-124e417cf71a-2800'
webbrowser
.
open
(
url
)
print
(
webbrowser
.
get
())
\ No newline at end of file
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