Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson3_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
542143ff
authored
Aug 21, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
dc6533ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
ffg.py
snake.py
ffg.py
View file @
542143ff
'''
#贪吃蛇是否撞墙
if x < 0 or x > 630 or y < 0 or y > 450: #如果蛇超出四个边界其中之一
exit
()
#退出
\ No newline at end of file
exit() #退出
#不碰身子
for i in range(len(snake)-1):
if snake[i] == snake[len(snake)-1]:
print("wuoa!")
'''
\ No newline at end of file
snake.py
View file @
542143ff
...
...
@@ -89,10 +89,10 @@ while True:#重复执行以下代码
#通过减1来遍历列表中从第1项到倒数第2项所有坐标
#绘制分数
info
=
'Score'
+
' '
+
str
(
score
)
#将
要打印的内容
info
=
'Score'
+
' '
+
str
(
score
)
#将
将要打印的内容赋值给变量
text
=
my_font
.
render
(
info
,
True
,(
0
,
0
,
0
))
#以纯黑色渲染,赋值给变量
screen
.
blit
(
text
,(
540
,
10
))
#在540,10渲染分数
#(0,0,0)是色盘,由三个0-255的数表示颜色,(0,0,0)指黑色
#(0,0,0)是色盘
数据
,由三个0-255的数表示颜色,(0,0,0)指黑色
pygame
.
display
.
update
()
#刷新屏幕,保证看到最新画面
FPSCLOCK
.
tick
(
3
)
#设置帧数(设置运行速度)
\ 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