Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson4_diy4

  • This project
    • Loading...
  • Sign in
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 44377ba0 authored 3 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent d9f6e227
Show whitespace changes
Inline Side-by-side
Showing with 66 additions and 0 deletions
  • background.png
  • last.png
  • logo.png
  • my_music.py
  • neuropol.ttf
  • next.png
  • play.png
  • stop.png
  • test.wav
background.png 0 → 100644
View file @ 44377ba0
background.png

133 KB

This diff is collapsed. Click to expand it.
last.png 0 → 100644
View file @ 44377ba0
last.png

3.79 KB

This diff is collapsed. Click to expand it.
logo.png 0 → 100644
View file @ 44377ba0
logo.png

40.9 KB

This diff is collapsed. Click to expand it.
my_music.py 0 → 100644
View file @ 44377ba0
import pygame
from pygame import locals
import os
pygame.init()
screen = pygame.display.set_mode((640,480))
background = pygame.image.load('background.png')
last = pygame.image.load('last.png')
logo = pygame.image.load('logo.png')
next = pygame.image.load('next.png')
stop = pygame.image.load('stop.png')
play = pygame.image.load('play.png')
font = pygame.font.Font('neuropol.ttf',20)
music_list = []
path = 'C:\\Users\\EDZ\\Desktop\\123'
num = -1
fps = pygame.time.Clock()
volume = 0.5
click = 0
play_button = stop
pygame.mixer.music.set_volume(volume)
for file in os.listdir(path):
if file[-4:] == '.wav' or file[-4:] == '.ogg':
music_list.append(file)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1:
x,y = event.pos
if x >= 270 and x <= 370 and y >= 330 and y <= 430:
if click == 0:
click = 1
pygame.mixer.music.pause()
play_button = play
else:
click = 0
pygame.mixer.music.unpause()
play_button = stop
if event.type == locals.KEYDOWN:
if event.key == locals.K_DOWN:
if volume > 0:
volume -= 0.01
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_UP:
if volume < 1:
volume += 0.01
pygame.mixer.music.set_volume(volume)
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
screen.blit(background,(0,0))
screen.blit(logo,(170,60))
screen.blit(play_button,(270,330))
screen.blit(last,(120,350))
screen.blit(next,(420,350))
pygame.display.update()
fps.tick(60)
\ No newline at end of file
This diff is collapsed. Click to expand it.
neuropol.ttf 0 → 100644
View file @ 44377ba0
File added
This diff is collapsed. Click to expand it.
next.png 0 → 100644
View file @ 44377ba0
next.png

3.87 KB

This diff is collapsed. Click to expand it.
play.png 0 → 100644
View file @ 44377ba0
play.png

12.1 KB

This diff is collapsed. Click to expand it.
stop.png 0 → 100644
View file @ 44377ba0
stop.png

11.6 KB

This diff is collapsed. Click to expand it.
test.wav 0 → 100644
View file @ 44377ba0
File added
This diff is collapsed. Click to expand it.
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment