Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson1_2
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
932f7c7e
authored
Jan 30, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
10e4bc3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
24 deletions
snake.py
snake.py
View file @
932f7c7e
import
pygame
from
pygame
import
locals
# 初始化pygame,为使用pygame做准备
pygame
.
init
()
bs
=
pygame
.
image
.
load
(
'bg.png'
)
kk
=
pygame
.
image
.
load
(
'right.png'
)
bb
=
pygame
.
image
.
load
(
'apple.png'
)
bo
=
pygame
.
image
.
load
(
'body.png'
)
# 创建一个窗口
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
while
True
:
for
i
in
pygame
.
event
.
get
():
if
i
.
type
==
locals
.
QUIT
:
exit
()
screen
.
blit
(
bs
,(
0
,
0
))
screen
.
blit
(
kk
,(
240
,
150
))
screen
.
blit
(
bb
,(
0
,
0
))
screen
.
blit
(
bo
,(
210
,
150
))
screen
.
blit
(
bo
,(
180
,
150
))
screen
.
blit
(
bo
,(
180
,
120
))
pygame
.
display
.
update
()
\ No newline at end of file
# list= ["袁术","公孙瓒","关羽","张飞","刘备","曹操"]
# print(list[2])
# print(list[:])
# print(list[:4])
# print(list[1:4])
# print(list[1:5])
# bros.insert(3,"诸葛亮")
# bros.append('赵云')
# bros.pop(1)
# bros.remove('张飞')
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'刘强'
,
66
,
'王猛'
,
89
,
'周亮'
,
98
]
name
=
'刘强'
power
=
66
hero
=
[
'赵一'
,
30
,
'丁二'
,
37
,
'孙五'
,
52
,
'王猛'
,
89
,
'周亮'
,
98
]
for
i
in
range
(
len
(
hero
)):
if
i
%
2
==
1
and
hero
[
i
]
>=
power
:
hero
.
insert
(
i
-
1
,
name
)
hero
.
insert
(
i
,
power
)
break
print
(
hero
)
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