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
3db02e09
authored
May 30, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
5402f3f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
snake.py
up.png
snake.py
View file @
3db02e09
import
pygame
def
selection_sort
(
arr
):
from
pygame
import
locals
n
=
len
(
arr
)
for
i
in
ran
range
(
n
):
min_index
=
i
for
j
in
range
(
i
+
1
,
n
):
if
arr
[
j
]
<
arr
[
min_index
]
min_index
=
j
arr
[
i
],
arr
[
min_index
]
=
arr
[
min_index
],
arr
[
i
]
return
arr
arr
=
[
64
,
25
,
12
,
22
,
11
]
sorted_arr
=
selection_sory
(
arr
)
print
(
"vhserhetheteth:"
,
sortedarr
)
def
sort_matrix
(
matrix
)
for
i
in
ran
range
(
len
(
matrix
))
matrix
[
i
]
=
selection_sort
(
matrix
[
i
])
return
matrix
matrix
=
[
[
64
,
25
,
12
],
[
22
,
11
,
99
],
[
45
,
56
,
89
]
# 初始化pygame,为使用pygame做准备
pygame
.
init
()
# 创建一个窗口
screen
=
pyg
.
ame
.
display
.
set_mode
((
660
,
480
),
0
,
32
)
while
True
:
for
event
in
pygame
.
get
():
if
event
.
Type
==
locals
.
QUIT
background
=
pygame
.
image
.
load
(
'bg.png'
)
right
=
pygame
.
image
.
load
(
'right.png'
)
food
=
pygame
.
image
.
load
(
'food.png'
)
body
=
pygame
.
image
.
load
(
'body.png'
)
\ No newline at end of file
up.png
View file @
3db02e09
2.05 KB
|
W:
|
H:
2.16 KB
|
W:
|
H:
2-up
Swipe
Onion skin
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