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
33aa329f
authored
Mar 28, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
2ffb9ec5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
3 deletions
a.py
my_music.py
a.py
0 → 100644
View file @
33aa329f
import
pygame
from
pygame
import
locals
pygame
.
init
()
pygame
.
display
.
set_mode
((
640
,
480
))
#stop_img = pygame.image.load('stop.png') # 暂停按钮
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
while
True
:
#screen.blit(stop_img, (270, 330))
for
event
in
pygame
.
event
.
get
():
print
(
event
)
if
event
.
type
==
12
:
exit
()
pygame
.
display
.
update
()
\ No newline at end of file
my_music.py
View file @
33aa329f
import
pygame
import
os
from
pygame
import
locals
pygame
.
init
()
# 初始化
...
...
@@ -11,16 +12,66 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img
=
pygame
.
image
.
load
(
'last.png'
)
# 上一曲按钮
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 中间logo
mu
=
os
.
listdir
(
r"C:\Users\86199\Desktop\text"
)
music
=
[]
for
i
in
mu
:
if
'.wav'
in
i
or
'.ogg'
in
i
:
music
.
append
(
i
)
screen
=
pygame
.
display
.
set_mode
((
660
,
480
))
num
=
-
1
NUM
=
num
click
=
0
volume
=
0.5
X
,
Y
=
170
,
60
while
True
:
for
event
in
pygame
.
event
.
get
():
????
if
event
.
type
==
12
:
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
273
and
volume
<=
1
:
volume
+=
0.1
if
event
.
key
==
274
and
volume
>=
0
:
volume
-=
0.1
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
if
event
.
button
==
1
:
x
,
y
=
event
.
pos
if
x
>=
270
and
y
>=
330
and
x
<=
370
and
y
<=
430
:
click
+=
1
if
x
>=
120
and
y
>=
350
and
x
<=
220
and
y
<=
400
:
num
-=
1
if
x
>=
420
and
y
>=
350
and
x
<=
520
and
y
<=
400
:
num
+=
1
# 绘制画面
screen
.
blit
(
bg_img
,
(
0
,
0
))
# 填充背景
screen
.
blit
(
stop_img
,
(
270
,
330
))
# 暂停按钮
screen
.
blit
(
logo_img
,
(
170
,
60
))
# 中间logo图
screen
.
blit
(
logo_img
,
(
X
,
Y
))
# 中间logo图
screen
.
blit
(
last_img
,
(
120
,
350
))
# 上一曲
screen
.
blit
(
next_img
,
(
420
,
350
))
# 下一曲
if
click
%
2
==
0
:
pygame
.
mixer
.
music
.
unpause
()
screen
.
blit
(
stop_img
,
(
270
,
330
))
else
:
pygame
.
mixer
.
music
.
pause
()
screen
.
blit
(
play_img
,
(
270
,
330
))
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
+=
1
if
num
>
len
(
music
)
-
1
:
num
=
0
pygame
.
mixer
.
music
.
load
(
music
[
num
])
pygame
.
mixer
.
music
.
play
()
if
NUM
!=
num
:
NUM
=
num
click
=
0
if
num
>
len
(
music
)
-
1
:
num
=
0
if
num
<
0
:
num
=
len
(
music
)
-
1
pygame
.
mixer
.
music
.
load
(
music
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
set_volume
(
volume
)
# 刷新画面
???
pygame
.
display
.
update
()
\ 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