Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson04_diy
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
70cc92e9
authored
Apr 30, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
51413712
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
my_music.py
my_music.py
View file @
70cc92e9
...
...
@@ -16,6 +16,8 @@ logo_img = pygame.image.load('logo.png') # 中间logo
volume
=
0.6
#加载音乐文件
pygame
.
mixer
.
music
.
load
(
"歌曲4.ogg"
)
click
=
0
play_button
=
stop_img
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
#判断事件类型是否为退出事件QUIT????
...
...
@@ -27,11 +29,19 @@ while True:
volume
=
1
#音量设为1
#设置播放音乐的音量
pygame
.
mixer
.
music
.
set_volume
(
volume
)
#判断是否按下down键
#声音减0.1
#判断音量是否小于0
#音量设为0
#设置播放音乐的音量
if
eventkey
==
lucals
.
KDOWN
:
#判断是否按下down键
volume
-=
1
#声音减0.1
if
volume
<
0
:
#判断音量是否小于0
colume
=
0
#音量设为0
pygame
.
mixer
.
music
.
set_volume
(
volume
)
#设置播放音乐的音量
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
#判断事件类型是否为鼠标按下MOUSEBUTTONDOWN
click
+=
1
#记录点击鼠标的次数加1
if
click
%
2
==
0
:
#判断是否为偶数
play_button
=
stop_img
#按钮为暂停按钮造型
pygame
.
mixer
.
music
.
unpause
()
#播放音乐
else
:
#否则
play_button
=
play_img
#按钮为播放按钮造型
pygame
.
mixer
.
music
.
pause
()
#暂停播放
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
#判断播放器没有正在播放音乐
pygame
.
mixer
.
music
.
play
()
#播放音乐
...
...
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