Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_diy2
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
39a0d44a
authored
2 months ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
b0dd0175
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
12 deletions
my_music.py
my_music.py
View file @
39a0d44a
...
@@ -12,6 +12,7 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
...
@@ -12,6 +12,7 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img
=
pygame
.
image
.
load
(
'last.png'
)
# 上一曲按钮
last_img
=
pygame
.
image
.
load
(
'last.png'
)
# 上一曲按钮
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 下一曲按钮
next_img
=
pygame
.
image
.
load
(
'next.png'
)
# 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 下一曲按钮
logo_img
=
pygame
.
image
.
load
(
'logo.png'
)
# 下一曲按钮
basic_font
=
pygame
.
font
.
Font
(
"neuropol.ttf"
)
music_list
=
[]
music_list
=
[]
path
=
os
.
path
.
join
(
"C:
\\
Users
\\
玛酷
\\
Desktop"
,
"mi"
)
path
=
os
.
path
.
join
(
"C:
\\
Users
\\
玛酷
\\
Desktop"
,
"mi"
)
...
@@ -31,12 +32,12 @@ while True:
...
@@ -31,12 +32,12 @@ while True:
exit
()
exit
()
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_
w
:
if
event
.
key
==
locals
.
K_
UP
:
volume
+=
0.1
volume
+=
0.1
if
volume
>
1
:
if
volume
>
1
:
volume
=
1
volume
=
1
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
if
event
.
key
==
locals
.
K_
s
:
if
event
.
key
==
locals
.
K_
DOWN
:
volume
-=
0.1
volume
-=
0.1
if
volume
<
0
:
if
volume
<
0
:
volume
=
0
volume
=
0
...
@@ -60,10 +61,10 @@ while True:
...
@@ -60,10 +61,10 @@ while True:
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
click
=
0
click
+=
2
music1
==
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
else
:
music_length
=
music1
.
get_length
()
click
+=
1
music_length
=
int
(
music_length
)
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
num
-=
1
num
-=
1
...
@@ -72,10 +73,12 @@ while True:
...
@@ -72,10 +73,12 @@ while True:
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
play_button
=
stop_img
play_button
=
stop_img
if
click
%
2
==
0
:
click
=
0
click
+=
2
music1
==
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
else
:
music_length
=
music1
.
get_length
()
click
+=
1
music_length
=
int
(
music_length
)
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
if
pygame
.
mixer
.
music
.
get_busy
()
==
False
:
num
+=
1
num
+=
1
...
@@ -83,11 +86,22 @@ while True:
...
@@ -83,11 +86,22 @@ while True:
num
=
0
num
=
0
pygame
.
mixer
.
music
.
load
(
os
.
path
.
join
(
path
.
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
os
.
path
.
join
(
path
.
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
music1
==
pygame
.
mixer
.
Sound
(
path
+
"
\\
"
+
music_list
[
num
])
music_length
=
music1
.
get_length
()
music_length
=
int
(
music_length
)
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
play_time
=
int
(
plau_time
/
1000
)
play_time
=
int
(
plau_time
/
1000
)
play_m
=
play_time
//
60
play_m
=
play_time
//
60
play_s
=
play_time
%
60
play_s
=
play_time
%
60
info
=
str
(
play_m
)
+
"."
=
str
(
play_s
)
if
play_s
<
10
:
play
==
"0"
+
str
(
play_s
)
info
=
str
(
play_m
)
+
"."
+
str
(
play_s
)
play_m
=
play_time
//
60
play_s
=
play_time
%
60
if
play_s
<
10
:
play
==
"0"
+
str
(
play_s
)
info2
=
str
(
music_m
)
+
"."
+
str
(
play_s
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
newRect
=
nem_logo
.
get_rect
(
center
(
320
,
200
))
newRect
=
nem_logo
.
get_rect
(
center
(
320
,
200
))
pos
=
(
newRect
[
0
])
.
newRect
[
i
]
pos
=
(
newRect
[
0
])
.
newRect
[
i
]
...
@@ -100,7 +114,10 @@ while True:
...
@@ -100,7 +114,10 @@ while True:
screen
.
blit
(
logo_img
,
(
170
,
60
))
screen
.
blit
(
logo_img
,
(
170
,
60
))
screen
.
blit
(
last_img
,
(
120
,
350
))
screen
.
blit
(
last_img
,
(
120
,
350
))
screen
.
blit
(
next_img
,
(
420
,
350
))
screen
.
blit
(
next_img
,
(
420
,
350
))
scoreSunf
=
basir_Font
.
render
,
True
,(
250
,
256
,
256
)
screen
.
bilt
(
scoreSunf
),(
120
,
440
)
scoreSunf2
=
basir_Font
.
render
(
"/"
+
info2
,
True
,(
0
,
0
,
0
))
screen
.
bilt
(
scoreSunf
),(
120
,
440
)
pygame
.
display
.
update
()
pygame
.
display
.
update
()
FPS
.
tick
(
60
)
FPS
.
tick
(
60
)
...
...
This diff is collapsed.
Click to expand it.
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