Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_4
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
c70c59da
authored
Jul 26, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d2bb2232
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
snake.py
snake.py
View file @
c70c59da
...
@@ -5,18 +5,18 @@ pygame.init()
...
@@ -5,18 +5,18 @@ pygame.init()
# 创建一个窗口
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
background
=
pygame
.
image
.
load
(
"bg.png"
)
background
=
pygame
.
image
.
load
(
"bg.png"
)
#载入背景图片
right
=
pygame
.
image
.
load
(
"right.png"
)
right
=
pygame
.
image
.
load
(
"right.png"
)
#载入右头图片
food
=
pygame
.
image
.
load
(
"apple.png"
)
food
=
pygame
.
image
.
load
(
"apple.png"
)
#载入食物图片
body
=
pygame
.
image
.
load
(
"body.png"
)
body
=
pygame
.
image
.
load
(
"body.png"
)
#载入身体图片
while
True
:
while
True
:
screen
.
blit
(
background
,(
0
,
0
))
screen
.
blit
(
background
,(
0
,
0
))
#画上背景
screen
.
blit
(
right
,(
240
,
120
))
screen
.
blit
(
right
,(
240
,
120
))
#画上右头
screen
.
blit
(
body
,(
210
,
120
))
screen
.
blit
(
body
,(
210
,
120
))
#画上身体
screen
.
blit
(
body
,(
180
,
120
))
screen
.
blit
(
body
,(
180
,
120
))
screen
.
blit
(
body
,(
180
,
90
))
screen
.
blit
(
body
,(
180
,
90
))
screen
.
blit
(
food
,(
360
,
300
))
screen
.
blit
(
food
,(
360
,
300
))
#画上食物
pygame
.
display
.
update
()
pygame
.
display
.
update
()
#刷新画面
for
event
in
pygame
.
event
.
get
():
#遍历玩家事件
for
event
in
pygame
.
event
.
get
():
#遍历玩家事件
if
event
.
type
==
locals
.
QUIT
:
#检测玩家是否按下退出
if
event
.
type
==
locals
.
QUIT
:
#检测玩家是否按下退出
exit
()
exit
()
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