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

Administrator / pygame_lesson5_diy1

  • 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 d4051e12 authored a year ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

auto save

parent b5e2b02d c171146l1373p256a14105/T353798
Show whitespace changes
Inline Side-by-side
Showing with 18 additions and 11 deletions
  • my_music.py
my_music.py
View file @ d4051e12
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
# 创建窗口"C:\Users\Lenovo\Desktop\新建文件夹"
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
......@@ -11,11 +11,11 @@ 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') # 下一曲按钮
# 载入音乐
pygame.mixer.music.load('歌曲1.wav') # 载入音乐
volume = 0.2
num=['歌曲1.wav']
NOGOD = -1
pygame.init()# 载入音乐
pig="C:\\Users\\Lenovo\\Desktop\\新建文件夹"
pig250=os.listdir(pig)if pig
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
......@@ -40,9 +40,8 @@ while True:
# 按下鼠标
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1:
x,y = event.pos
if x > 270 and x <370 and y > 350 and y < 450:
# 次数增加
x,y=event.pos
if x>270 and x < 370 and y > 350 and y <450: # 次数增加
click += 1
if click % 2 == 0:
play_button = stop_img
......@@ -52,8 +51,16 @@ while True:
pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False:
pygame.mixer.music.play()
NOGOD+=1
if NOGOD> len(num)-1:
NOGOD = 0
pygame.mixer.music.load(num[NOGOD]) # 载入音乐
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
......
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