Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_3
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
6fd8f386
authored
May 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f3611b9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
snake.py
snake.py
View file @
6fd8f386
import
pygame
import
pygame
#导入模块
from
pygame
import
locals
from
pygame
import
locals
#导入事件模块
# 初始化pygame,为使用pygame做准备
# 初始化pygame,为使用pygame做准备
pygame
.
init
()
pygame
.
init
()
# 创建一个窗口
# 创建一个窗口
ck
=
pygame
.
display
.
set_mode
((
600
,
600
))
a1
=
pygame
.
image
.
load
(
'apple.png'
)
#苹果
while
True
:
a2
=
pygame
.
image
.
load
(
'right.png'
)
#头部
for
i
in
pygame
.
event
.
get
():
a3
=
pygame
.
image
.
load
(
'body.png'
)
#身体
if
i
.
type
==
locals
.
QUIT
:
a4
=
pygame
.
image
.
load
(
'bg.png'
)
#画布
exit
()
ck
=
pygame
.
display
.
set_mode
((
600
,
600
))
#创建窗口
\ No newline at end of file
while
True
:
#无限循环(保存窗口)
for
i
in
pygame
.
event
.
get
():
#遍历
if
i
.
type
==
locals
.
QUIT
:
#条件判断
exit
()
#条件符合结束程序
ck
.
blit
(
a4
,(
0
,
0
))
#渲染素材
ck
.
blit
(
a1
,(
450
,
450
))
ck
.
blit
(
a3
,(
210
,
120
))
ck
.
blit
(
a3
,(
180
,
120
))
ck
.
blit
(
a3
,(
180
,
90
))
ck
.
blit
(
a2
,(
240
,
120
))
pygame
.
display
.
update
()
#刷新窗口
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