Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
pygame_lesson6_diy3
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
cb9814ce
authored
2 years ago
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
8de84095
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
diy.py
my_music.py
diy.py
View file @
cb9814ce
...
@@ -5,6 +5,11 @@ def kun():
...
@@ -5,6 +5,11 @@ def kun():
if
unit
==
'q'
:
if
unit
==
'q'
:
break
break
else
:
else
:
try
:
new_input
=
int
(
unit
)
except
:
print
(
"要输入整数"
)
else
:
total
.
append
(
unit
)
total
.
append
(
unit
)
print
(
total
)
print
(
total
)
kun
()
kun
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
my_music.py
View file @
cb9814ce
...
@@ -6,14 +6,14 @@ pygame.init()
...
@@ -6,14 +6,14 @@ pygame.init()
fpsclock
=
pygame
.
time
.
Clock
();
fpsclock
.
tick
(
100
)
fpsclock
=
pygame
.
time
.
Clock
();
fpsclock
.
tick
(
100
)
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
screen
=
pygame
.
display
.
set_mode
((
640
,
480
))
bg_img
=
pygame
.
image
.
load
(
'background.png'
)
# 背景图
bg_img
pygame
.
image
.
load
(
'background.png'
)
# 背景图
play_img
=
pygame
.
image
.
load
(
'play.png'
)
# 播放按钮
play_img
=
pygame
.
image
.
load
(
'play.png'
)
# 播放按钮
stop_img
=
pygame
.
image
.
load
(
'stop.png'
)
# 暂停按钮
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'
)
# 下一曲按钮
my_font
=
pygame
.
font
.
Font
(
"neuropol.ttf"
,
20
)
my_font
=
pygame
.
font
.
Font
(
"neuropol.ttf"
,
20
)
music_li
s
t
=
[]
music_lit
=
[]
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
test"
path
=
"C:
\\
Users
\\
Administrator
\\
Desktop
\\
test"
filelist
=
os
.
listdir
(
path
)
filelist
=
os
.
listdir
(
path
)
num
=
-
1
num
=
-
1
...
@@ -24,7 +24,7 @@ volume = 0.2
...
@@ -24,7 +24,7 @@ volume = 0.2
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
click
=
0
click
=
0
play_button
=
stop_img
play_button
=
stop_img
angle
=
0
angle
0
while
True
:
while
True
:
for
event
in
pygame
.
event
.
get
():
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
locals
.
QUIT
:
if
event
.
type
==
locals
.
QUIT
:
...
@@ -32,7 +32,7 @@ while True:
...
@@ -32,7 +32,7 @@ while True:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
type
==
locals
.
KEYDOWN
:
if
event
.
key
==
locals
.
K_w
:
if
event
.
key
==
locals
.
K_w
:
v
olume
+=
0.1
v
+=
0.1
if
volume
>
1
:
if
volume
>
1
:
volume
=
1
volume
=
1
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
...
@@ -42,8 +42,8 @@ while True:
...
@@ -42,8 +42,8 @@ while True:
volume
=
0
volume
=
0
pygame
.
mixer
.
music
.
set_volume
(
volume
)
pygame
.
mixer
.
music
.
set_volume
(
volume
)
if
event
.
type
==
locals
.
MOUSEBUTTONDOWN
:
if
event
.
type
==
locals
.
MOUS
B
EBUTTONDOWN
:
if
event
.
button
==
1
:
if
event
.
button
==
1
x
,
y
=
event
.
pos
x
,
y
=
event
.
pos
if
x
>
270
and
x
<
370
and
y
>
350
and
y
<
450
:
if
x
>
270
and
x
<
370
and
y
>
350
and
y
<
450
:
click
+=
1
click
+=
1
...
@@ -54,7 +54,7 @@ while True:
...
@@ -54,7 +54,7 @@ while True:
play_button
=
play_img
play_button
=
play_img
pygame
.
mixer
.
music
.
pause
()
pygame
.
mixer
.
music
.
pause
()
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
400
:
if
x
>
420
and
x
<
520
and
y
>
350
and
y
<
400
:
num
+=
1
num
1
if
num
>
len
(
music_list
)
-
1
:
if
num
>
len
(
music_list
)
-
1
:
num
=
0
num
=
0
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
...
@@ -65,7 +65,7 @@ while True:
...
@@ -65,7 +65,7 @@ while True:
else
:
else
:
click
+=
1
click
+=
1
if
x
>
120
and
x
<
220
and
y
>
350
and
y
<
400
:
if
x
>
120
and
<
220
and
y
>
350
and
y
<
400
:
num
-=
1
num
-=
1
if
num
<
0
:
if
num
<
0
:
num
=
len
(
music_list
)
-
1
num
=
len
(
music_list
)
-
1
...
@@ -81,14 +81,12 @@ while True:
...
@@ -81,14 +81,12 @@ while True:
num
+=
1
num
+=
1
if
num
>
len
(
music_list
)
-
1
:
if
num
>
len
(
music_list
)
-
1
:
num
=
0
num
=
0
pygame
.
mixe
r
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixe
.
music
.
load
(
path
+
"
\\
"
+
music_list
[
num
])
pygame
.
mixer
.
music
.
play
()
pygame
.
mixer
.
music
.
play
()
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
new_logo
=
pygame
.
transform
.
rotate
(
logo_img
,
angle
)
new_rect
=
new_logo
.
get_rect
(
center
=
(
320
,
200
))
new_rect
=
new_logo
.
get_rect
(
center
=
(
320
,
200
))
pos
=
(
new_rect
[
0
],
new_rect
[
1
])
pos
=
(
new_rect
[
0
],
new_rect
[
1
])
if
play_button
==
stop_img
:
if
playe
=
pygame
.
mixer
.
music
.
get_pos
()
angle
+=
1
play_time
=
pygame
.
mixer
.
music
.
get_pos
()
mmm
=
(
play_time
//
1000
)
//
60
mmm
=
(
play_time
//
1000
)
//
60
sss
=
(
play_time
//
1000
)
%
60
sss
=
(
play_time
//
1000
)
%
60
new_render
=
str
(
mmm
)
+
':'
+
str
(
sss
)
new_render
=
str
(
mmm
)
+
':'
+
str
(
sss
)
...
...
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