Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson5_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
1a4f9e1c
authored
Mar 27, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
2aadbf28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
15 deletions
my_music.py
my_music.py
View file @
1a4f9e1c
...
@@ -27,7 +27,7 @@ for i in file:
...
@@ -27,7 +27,7 @@ for i in file:
volume
=
0.2
volume
=
0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 初始播放音量
click
=
0
click
=
0
click_xy
=
(
0
,
0
)
play_button
=
stop_img
play_button
=
stop_img
num
=
0
num
=
0
while
True
:
while
True
:
...
@@ -48,13 +48,10 @@ while True:
...
@@ -48,13 +48,10 @@ while True:
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 按下鼠标
# 按下鼠标
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
# 获取点击处的坐标
# 获取点击处的坐标
click_xy
=
event
.
pos
click_x
=
click_xy
[
0
]
click_y
=
click_xy
[
1
]
# 按下音乐暂停/开始按钮处
if
click_x
>
270
and
click_x
<
370
and
click_y
>
350
and
click_y
<
450
:
# 次数增加
# 次数增加
click
+=
1
click
+=
1
if
click
%
2
==
0
:
if
click
%
2
==
0
:
...
@@ -63,16 +60,7 @@ while True:
...
@@ -63,16 +60,7 @@ while True:
else
:
else
:
play_button
=
play_img
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
pygame
.
mixer
.
music
.
pause
()
# 按下上一曲
if
click_x
>
120
and
click_x
<
220
and
click_y
>
350
and
click_y
<
400
:
num
-=
1
if
num
<
0
:
num
=
len
(
music_list
)
-
1
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
click
=
0
play_button
=
stop_img
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
+=
1
num
+=
1
...
...
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